I'm sure it has been addressed somewhere else in the forum if someone can point me to the specific thread. All the ones I've found aren't describing the same problem.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
SetTrailStop
Collapse
X
-
SetTrailStop
I'm having trouble programming a trailing stop. If the same bar goes profitable, it does not initiate the trailing stop, it just creates a sell order at the entry price. I've created a simple key reversal up strategy with a trailing stop and attached it just to clarify what is happening. If the opening bar range is within the trailing stop value, and the trade continues to the next bar, the trailing stop works perfectly. Somehow, it only causes a problem on the same bar.
I'm sure it has been addressed somewhere else in the forum if someone can point me to the specific thread. All the ones I've found aren't describing the same problem. -
Comment
-
wallabee, please try backtesting on an instrument you can actually trade, like DIA for the DJIA index, or the YM dow future. I have a feeling the 200 "tick" trailing stop you're using doesn't like the index pricing system. You could also try with a very large trailing stop, like 20000 for 200 points on that DJIA index.AustinNinjaTrader Customer Service
Comment
-
No change
I have tried it on multiple instruments. Including AAPL which some screenshots are attached here. The problem doesn't exist if the order continues to the next bar, it is only if it goes beyond the range of the trailing value on the same bar, even just going profitable, not necessarily even triggering the stop on the same bar. I have attached the simple KRU strategy that I am using just in case somebody can find something wrong with the programming. I have tried changing it to percent values as well and it doesn't change anything.
The entry formula is not a problem, it works fine; it's just the trailing stop. As you can see from the AAPL screenshots, the trades on 1/31 and 2/1 should have gone profitable, yet do not get calculated correctly. The trailing stop is set at 100 ticks, or $1. Thanks for the help.Last edited by wallabee13; 04-16-2011, 11:29 PM.
Comment
-
I have never seen the problem, but then again, I have always named my signals. Try using a named signal. If you do not have the problem then, I would venture to suggest that you have uncovered a bug.
Code:protected override void Initialize() { SetTrailStop("[COLOR="Red"]KRLong[/COLOR]", CalculationMode.Ticks, TrailingSto, false); CalculateOnBarClose = false; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Condition set 1 if (Low[0] < Low[1] && Close[0] > SMA(SMA3)[0] && Close[0] > Open[0]) { EnterLong(DefaultQuantity, "[COLOR="red"]KRLong[/COLOR]"); } }
Comment
-
Thanks
Thanks Koganam, I tried labeling the signals and unfortunately it doesn't change anything :/. I tried adjusting it to a profit target, stop loss and everything works fine, so it's not in the code. I always come up with the easy to solve problems!
Comment
-
Originally posted by wallabee13 View PostThanks Koganam, I tried labeling the signals and unfortunately it doesn't change anything :/. I tried adjusting it to a profit target, stop loss and everything works fine, so it's not in the code. I always come up with the easy to solve problems!
Comment
-
wallabee, you may want to start backtesting with an intrabar granularity so the trailing stops actually trail up on those big bars instead of being stopped out immediately.AustinNinjaTrader Customer Service
Comment
-
Austin, thanks for the information. I took a look at this before, and I think I understand how it operates. Still, after reprogramming the strategy, it has not changed the outcome (I tried 1 minute and 1 tick). Attached is a screenshot of the same problem. Also, the strategy file is uploaded, updated with the added period type, 1 minute. Somebody let me know if I programmed anything incorrectly, because I'm not 100% sure about the new programming.
Thanks
ps. Completely separate issue: The added granularity actually changed it so if a "long" is triggered on the last bar of the day, 10:00am local (Hawaiian), it opens a position at the open of the new day, 3:31am local, and closes with a "exit on close" of previous day, 10:00am local. I don't care about fixing this for me (can always set "exit on close" to false, or set time < 10:00am), just to let y'all know about the programming issues. Trade #54 on the screenshot added.
Comment
-
Hi wallabee13,
I took a look at your screenshots and ran some tests here. This is what looks like is happening:
For bars where High - Open >= your trail stop value, this will result in a simulated movement of the trail stop from its initial value, which then results in a fill. The price level that the stop loss is moved to is included on the entry bar.
This is unfortunately a limitation of backtesting. You don't really have the full sequence. Adding a smaller series will not resolve this, as Set statements look at all bar series to determine if there should be a fill.
Ideally you should test SetTrailStop() in a live or simulated live environment, like market replay or with the simulated data feed.
If you want to backtest trailing stop functionality, you should move away from the Set statements and add the smaller time frame for increased granularity. You can submit Exit statements like ExitLongStop() and ExitShortStop() to a specific series and custom code dynamic movement of these orders.Last edited by NinjaTrader_RyanM1; 04-21-2011, 09:08 AM.Ryan M.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by benmarkal, Yesterday, 12:52 PM
|
3 responses
22 views
0 likes
|
Last Post Today, 05:22 AM | ||
Started by helpwanted, Today, 03:06 AM
|
1 response
18 views
0 likes
|
Last Post Today, 03:35 AM | ||
Started by Brevo, Today, 01:45 AM
|
0 responses
11 views
0 likes
|
Last Post
by Brevo
Today, 01:45 AM
|
||
Started by aussugardefender, Today, 01:07 AM
|
0 responses
6 views
0 likes
|
Last Post Today, 01:07 AM | ||
Started by pvincent, 06-23-2022, 12:53 PM
|
14 responses
244 views
0 likes
|
Last Post
by Nyman
Today, 12:47 AM
|
Comment