NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM 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.

Reply
 
Thread Tools Display Modes
Old 09-26-2007, 03:58 PM   #16
dgregor5
Senior Member
 
Join Date: Jul 2007
Posts: 225
Thanks: 0
Thanked 0 times in 0 posts
Default

This is not on a gap down where this is happening.

Example during a backtest.....

1/ prior bar hits high of 13955 & closes at 13942.
2/ TrailStop updated on bar close (i.e. set to true) & is set to 1 (lowest value I believe that is possible).
3/ current bar OHLC = 13942, 13947, 13921, 13928.
4/ trade exits on current bar at 13954.

so it would appear that stoploss is set to 13955 at the close of the prior bar & then since the price at the next bar open is 13 less than stoploss set point it assumes a 'gap' & therefore exits in midair.

but why would one in real time get a fill at higher price than the current market price --- I cannot understand this.

thx DG
dgregor5 is offline  
Reply With Quote
Old 09-26-2007, 04:34 PM   #17
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

A fill price of 13954 means that the stop price going into the current bar was at at a price higher than the low of the current bar and thus you are filled at your stop price + commission values.

I realize you say that your stop was changed to a price of 1 but if that was the case, your stop would not have triggered. You can verify this by enabling TraceOrders = true in the Initialize() method and reviewing the Output window.

The simulator or exchange can fill you at a price higher than the market. Usually does not happen but it can.
NinjaTrader_Ray is offline  
Reply With Quote
Old 09-27-2007, 02:24 PM   #18
dgregor5
Senior Member
 
Join Date: Jul 2007
Posts: 225
Thanks: 0
Thanked 0 times in 0 posts
Default

Ray - thx for your guidance on this.

The way I see it is that the simulator is always filling me at the stop price (= 1 tick lower than high of prior bar) every time the current bar high is lower than prior bar high & if the trailstop value been set to <= 0.

I don't think you will agree.......
but I can send the strategy for you to back test if you wish.

thx
David
dgregor5 is offline  
Reply With Quote
Old 09-27-2007, 02:47 PM   #19
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Please use the TraceOrders option and check the price of your "sell" stop order at the fill in question. If the price is a value of <= 0, let me know.
NinjaTrader_Ray is offline  
Reply With Quote
Old 09-27-2007, 03:07 PM   #20
dgregor5
Senior Member
 
Join Date: Jul 2007
Posts: 225
Thanks: 0
Thanked 0 times in 0 posts
Default

With TraceOrders, Value = 1 (I presume this is the minimum value, since the trailstop calculation actually takes the value < 0).

So my prior comment still stands.............The way I see it is that the simulator is always filling me at the stop price (= 1 tick lower than high of prior bar) every time the current bar high is lower than prior bar high & if the trailstop value been set to <= 0 (.........sets itself to value=1).
dgregor5 is offline  
Reply With Quote
Old 09-27-2007, 06:51 PM   #21
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Is this a "BUY" or "SELL" stop order?
NinjaTrader_Ray is offline  
Reply With Quote
Old 09-28-2007, 02:43 PM   #22
dgregor5
Senior Member
 
Join Date: Jul 2007
Posts: 225
Thanks: 0
Thanked 0 times in 0 posts
Default

since this is a long strategy, it is a sell stop order to exit. DG
dgregor5 is offline  
Reply With Quote
Old 09-28-2007, 03:05 PM   #23
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Hi dgregor5,

Lets try to get to the root of this problem. Would you mind sending me a simple as possible strategy that displays the issues you are experiencing along with a replay file that highlights the problem? Thank you.
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-28-2007, 03:49 PM   #24
dgregor5
Senior Member
 
Join Date: Jul 2007
Posts: 225
Thanks: 0
Thanked 0 times in 0 posts
Default

Josh - sent a strategy via email to support for you to backtest. thx. David
dgregor5 is offline  
Reply With Quote
Old 09-28-2007, 04:41 PM   #25
dgregor5
Senior Member
 
Join Date: Jul 2007
Posts: 225
Thanks: 0
Thanked 0 times in 0 posts
Default

testing out a similar dynamic trailing stop strategy with simulated real time data feed observed the following:
Conditions:
1/ CalculateOnBarClose=True.
2/ SetTrailStop set in OnBarUpdate section.
3/ trail stop value sent to output window at onbarclose.
4/ TraceOrders = true in initialise method.

Obervations with real time simulated feed:
1/ If end of bar trail stop calculation on prior bar leads to stop price > open price of current bar, then trade exits immediately at open price of current bar. this is exactly what I expect.

Observations in backtestmode:
1/ If end of bar trail stop calculation on prior bar leads to stop price > open price of current bar, then trade exits immediately at stop price ---- hence why certain trades exit in mid-air.

Isn't this an issue !!?!?!

Again am I being dumb ?!?!?!?

thx
DG
dgregor5 is offline  
Reply With Quote
Old 09-28-2007, 04:46 PM   #26
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

No, you are not being dumb. I understand your concern and will see what I can do. Would you mind sending me the things you sent through support to josh [at] ninjatrader [dot] com? Thanks.
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-28-2007, 04:52 PM   #27
dgregor5
Senior Member
 
Join Date: Jul 2007
Posts: 225
Thanks: 0
Thanked 0 times in 0 posts
Default

Josh - have sent the files. thx. DG
dgregor5 is offline  
Reply With Quote
Old 09-29-2007, 06:28 PM   #28
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Hi dgregor5,

The issue will be fixed for NinjaTrader 6.5. In the meantime you can do this to fix the issue on your NinjaTrader 6.0.1000.5 install.
  1. Save and overwrite @DefaultFillType.cs at \My Documents\NinjaTrader 6\bin\Custom\Types\
  2. Open up the NinjaScript Editor on any NinjaScript and hit compile
  3. The fill algorithm should now be updated and you can see the effect in your backtests
Again, thanks for finding and pointing this out.
Attached Files
File Type: cs @DefaultFillType.cs (4.4 KB, 52 views)
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-30-2007, 04:46 AM   #29
dgregor5
Senior Member
 
Join Date: Jul 2007
Posts: 225
Thanks: 0
Thanked 0 times in 0 posts
Default

Hey Josh - great turnaround. thx for your assistance. Now works as expected. David
dgregor5 is offline  
Reply With Quote
Old 09-30-2007, 02:24 PM   #30
dgregor5
Senior Member
 
Join Date: Jul 2007
Posts: 225
Thanks: 0
Thanked 0 times in 0 posts
Default

Josh:
I am now seeing similar mid-air exits when using a dynamic profit target (using SetProfitTarget from within OnBarUpdate). This time the mid-air exits are always below where the exit should be........ (n.b. this is a long strategy again)

Similar issue ???

thx
David
dgregor5 is offline  
Reply With Quote
Reply

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
Switching from stop to trailing MrBaffalo Strategy Development 1 02-02-2007 03:33 AM
Dynamic Trailing Stops whitmark Suggestions And Feedback 4 05-09-2006 11:57 PM
Can't get trailing stop Savage1701 Automated Trading 1 04-07-2006 08:03 AM
Trailing Stop Question underground Miscellaneous Support 3 06-06-2005 07:11 AM
Dynamic Stop and Adjust OIF scjohn Automated Trading 19 03-24-2005 04:37 AM


All times are GMT -6. The time now is 08:20 PM.