NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 11-08-2008, 06:27 PM   #1
Tight Face
Member
 
Join Date: Apr 2008
Posts: 72
Thanks: 0
Thanked 0 times in 0 posts
Default ExitLong()/ExitShort() not working as expected

I have setup a pyramiding type entry strategy with two BarsArray instruments.

So here is a typical example: I enter short, and then pyramid a second level of shares. Then when the level2 exit threshold is reached, I want to close out the second entry, and then finally the level1 exit threshold is reached, I want to close out the very first entry.

Code:
EnterShort(1,level1,Instruments[1].MasterInstrument.Name + "_ES_1");
EnterShort(1,level2,Instruments[1].MasterInstrument.Name + "_ES_2");
...
ExitShort(1,level2,Instruments[1].MasterInstrument.Name + "_XS_2",Instruments[1].MasterInstrument.Name + "_ES_2");
ExitShort(1,level1,Instruments[1].MasterInstrument.Name + "_XS_1",Instruments[1].MasterInstrument.Name + "_ES_1");
It should look like: Enter level1, Enter level2, Exit level2, Exit level1...

The problem is, this works sometimes, but not always. Even playing back over the replay data it is different. Sometimes the level2 exit is tied to the level1 entry, and sometimes the level2 exit is tied to the level1 AND level2 entry.

In the attached image, the red line should not be displayed.

Also, I am wondering why the above overloaded exit method requires that a quantity be specified? If I am supplying the entrySignal, shouldn't the method figure out what the quantity is already?

Maybe something like this:
ExitShort(int barsInProgressIndex, string signalName, string fromEntrySignal)

Thanks.
Attached Images
File Type: png SSO 10_29_2008 (3 Seconds).png (36.5 KB, 23 views)
Tight Face is offline  
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ExitShort / ExitLong Not Exiting Ari Gold General Programming 8 07-19-2008 12:29 AM
When in 2009 is NT7 expected? Re: Memory footprint bluelou Miscellaneous Support 11 06-22-2008 05:57 PM
DrawTextFixed not update as expected goover General Programming 2 03-04-2008 08:19 PM
ExitShort() / ExitLong() andrewbee General Programming 1 02-06-2008 10:57 AM
ExitLong and ExitShort mazachan Strategy Development 3 07-30-2007 03:15 PM


All times are GMT -6. The time now is 11:54 PM.