![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Oct 2008
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
|
I'm testing out a strategy and had an unexpected entry. Last night the strategy was running and entered a position. After my broker reset I had to (argh!) restart NT and setup my strategies again. Later, the strategy entered an additional position even though EntriesPerDirection is 1.
How do I prevent this from happening? Code:
1/29/2009 23:53 Default Verifying license at primary server... 1/29/2009 23:53 Default Current license: Type=Regular State=Verified StartDate=10/17/2008 EndDate=12/30/2099 Collective2 Dtn ESignal External OpenTick Provider2 Replay Simulator Yahoo Gain MBTrading AutomatedTrading AdvancedStrategyManagement BasicEntry Charting LiveTrading SystemDevelopment 1/29/2009 23:53 Default Session Break (Version 6.5.1000.8) 1/29/2009 23:53 Default Automated trading disabled 1/29/2009 23:53 Connection MBTrading: Primary connection=Connecting Price feed=Connecting 1/29/2009 23:53 Default Connected to quote server (prc130) 1/29/2009 23:53 Default Connected to order server 1/29/2009 23:53 Default Forex: Maintenance completed trading resumed. 1/29/2009 23:53 Default Connected to perm server 1/29/2009 23:53 Connection MBTrading: Primary connection=Connected Price feed=Connected 1/29/2009 23:53 Position Instrument='$USDCAD' Account='C2Test' Avg price=1.2266 Quantity=0.01M Market position=Long 1/29/2009 23:54 Connection ESignal: Primary connection=Connecting Price feed=Connecting 1/29/2009 23:54 Connection ESignal: Primary connection=Connected Price feed=Connected 1/29/2009 23:58 Strategy Starting NinjaScript strategy 'NMAStrat/f6819c13f034450e9c9ecdc9424c0fc7' : On starting a real-time strategy - StrategySync=WaitUntilFlat EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=ByStrategyPosition ErrorHandling=StopStrategyCancelOrdersClosePositions ExitOnClose=False Set order quantity by=DefaultQuantity 1/30/2009 3:31 Strategy Cancelling any remaining strategy orders 1/30/2009 4:00 Order Order='09b335f5a63248cab02ccb97b1f80339/C2Test' Name='BTO' New State=PendingSubmit Instrument='$USDCAD' Action=Buy Limit price=0 Stop price=0 Quantity=0.01M Type=Market Filled=0 Fill price=0 Error=NoError Native error='' 1/30/2009 4:00 Order Order='09b335f5a63248cab02ccb97b1f80339/C2Test' Name='BTO' New State=Working Instrument='$USDCAD' Action=Buy Limit price=0 Stop price=0 Quantity=0.01M Type=Market Filled=0 Fill price=0 Error=NoError Native error='' 1/30/2009 4:00 Order Order='09b335f5a63248cab02ccb97b1f80339/C2Test' Name='BTO' New State=Accepted Instrument='$USDCAD' Action=Buy Limit price=0 Stop price=0 Quantity=0.01M Type=Market Filled=0 Fill price=0 Error=NoError Native error='' 1/30/2009 4:00 Execution Execution='25b953ecc1e0460e8a3edbc8a3d731de' Instrument='$USDCAD' Account='C2Test' Exchange=Default Price=1.2323 Quantity=0.01M Market position=Long Operation=Insert Order='09b335f5a63248cab02ccb97b1f80339' Time='1/30/2009 4:00:00 AM' Multiplier=1E-05 Rate=0.811754200827989 1/30/2009 4:00 Order Order='09b335f5a63248cab02ccb97b1f80339/C2Test' Name='BTO' New State=Filled Instrument='$USDCAD' Action=Buy Limit price=0 Stop price=0 Quantity=0.01M Type=Market Filled=10000 Fill price=1.2323 Error=NoError Native error='' 1/30/2009 4:00 Position Instrument='$USDCAD' Account='C2Test' Avg price=1.22945 Quantity=0.02M Market position=Long Operation=Update Currency=Unknown
Last edited by mdrichards; 01-30-2009 at 11:59 AM.
|
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
A NinjaScript strategy does not know what your account position is. If you restart your strategy it will recalculate out a strategy position. EntriesPerDirection governs your strategy position not your account position. You need to sync the two manually.
http://www.ninjatrader-support2.com/...ead.php?t=4033
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 | |
|
Junior Member
Join Date: Oct 2008
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
The lack of state in strategies seems like a major problem. I can not figure out how I need to configure NT to properly manage my positions based on the strategies I've created. I'm forced to restart NT and setup my strategies every 24 hours because NT lacks the ability to gracefully handle the broker reset. |
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
No. Your strategy never knows what is in your account. WaitUntilFlat means wait until your strategy position is flat before submitting live orders. You need to manually ensure your strategy position is the same as your account position.
If you are using WaitUntilFlat all you need to do is flatten your account position before starting it.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 | |
|
Junior Member
Join Date: Oct 2008
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
|
|
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
As discusssed, a NinjaScript strategy never knows what your account position is. You need to manually sync the two.
If you restart your strategy it will proceed as it deems based off of the calculated strategy position. You need to reconcile any differences yourself between the account position versus the strategy position.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 | |
|
Junior Member
Join Date: Oct 2008
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
|
|
|
|
|
|
|
#8 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
I am not suggesting one option is better than the other. If you want to use WaitUntilFlat the way you sync your account to strategy is by flattening your account. If you select a different option you need to follow the suggestions as described in the link I posted earlier.
As discussed, you do not make the strategy position match anything. A NinjaScript strategy does not know anything about your account position. You sync the account position to the strategy position. Announcements will be made when appropriate about what NT7 can provide in syncing options.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#9 | ||
|
Junior Member
Join Date: Oct 2008
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
Quote:
This is incredibly backwards logic. I should not have to make live trades, paying extra commissions, to get a strategy to continue managing a position that it opened simply because NT forced me to restart it. |
||
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
Josh will respond to your post on Monday. Thank you for your patience.
Ben
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
The two options you have are flatten your account or manually sync your account to your strategy. If you use Wait until Flat, you will want to flatten your account before strategy start. If you use Execute live then you will want to follow what is outlined in the prior link provided.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| chart load error historical data error | Mike_32 | Charting | 4 | 11-20-2008 07:24 AM |
| Error on loading chart data: Native error 14 | CJ888 | Charting | 8 | 07-20-2006 10:16 PM |