View Full Version : Indicator Delay in Strategy
shliang
10-06-2007, 05:32 AM
Hi all,
I'm new to NinjaTrader and trying to implement a strategy that's based on the Swing indicator. But I notice the indicator doesn't behave as I expect.
Suppose the Strength parameter of Swing is set to 5, then a support is confirmed when the 5th bar is finished if other criteria fulfill. I.e., a support is formed with a minimum delay of 5 bars. But I observed in the strategy, it needs 2 x Strength bars (including the support bar itself, and in this case 10 bars) to confirm.
Anyone ever noticed similar issues?:confused:
shliang
10-06-2007, 05:34 AM
BTW, if I move the historical chart from left to right incrementally, the support is drawn when the 5th bar closes (not including the support bar). -- This is what I expect since no matter how the price evolves, the support won't change afterwards.
NinjaTrader_Ray
10-06-2007, 08:24 AM
Are you saying that:
Swing(5).SwingHighBar(0, 1, CurrentBar)
would return a value of 10 once the last swing high is confirmed?
shliang
10-06-2007, 10:17 AM
Exactly, Ray!
I haven't even noticed this. Seems I'm really very new, heh
Swing(x).SwingHighBar(0,1,CurrentBar) & Swing(x).SwingLowBar(0,1,CurrentBar) should always return x at the bar when support / resistance is confirmed.
Are you saying that:
Swing(5).SwingHighBar(0, 1, CurrentBar)
would return a value of 10 once the last swing high is confirmed?
shliang
10-06-2007, 10:59 AM
The problem is solved.
I tried the same program on my laptop and got different results. Here is the cuase:
I downloaded and installed the AutoTrendLine indicator from this forum. The source code @Swing.cs bundled with it is buggy!!:(
Please do not overwrite the original @Swing.cs at import.
Ray, thank you for the help.
NinjaTrader_Josh
10-06-2007, 12:46 PM
shliang thanks for pointing this out.
shliang
10-06-2007, 11:45 PM
The new Swing.SwingHighBar/SwingLowBar returns Strength+1 when high/low is confirmed.
I've expected it to be Strength.
NinjaTrader_Josh
10-07-2007, 12:21 AM
Strength? Swing(5).SwingHighBar/SwingLowBar should return how many bars ago the new high/low value was found.
Which new version are you referring to?
shliang
10-07-2007, 12:38 AM
Strength? Swing(5).SwingHighBar/SwingLowBar should return how many bars ago the new high/low value was found.
Which new version are you referring to?
NinjaTrader Version 6.0.1000.5
For Swing(5), high/low is confirmed when the 5th bar closes. At that exact moment, the high/low bar is 5 bars ago.
E.g., we have the following Open/Close series,
6/5, 5/4, 4/3, 3/2, 2/1, 1/0, 1/2, 2/3, 3/4, 4/5, 5/6, ...
1/0 is confirmed to be the Low Bar when the last 5/6 bar closes. 1/0 is 5 bars ago
NinjaTrader_Josh
10-07-2007, 01:05 AM
Okay I see what you are referring to, but I believe it is behaving as expected. When the 5th bar closes you are no longer on the 5th bar anymore. You are now on the 6th bar thus the print will say 6 bars ago instead of 5 bars ago.
shliang
10-07-2007, 01:08 AM
Okay I see what you are referring to, but I believe it is behaving as expected. When the 5th bar closes you are no longer on the 5th bar anymore. You are now on the 6th bar thus the print will say 6 bars ago instead of 5 bars ago.
I checked Close[0], it refers to the 6th bar. At the time the 5th closes, the close price of the 6th bar should not be invisible!
NinjaTrader_Josh
10-07-2007, 01:16 AM
I'm sorry I am not quite following you. The close of the 6th bar is not invisible. If this is running in real-time the Close[0] of the 6th bar will return the latest price of the current bar if you have CalculateOnBarClose set to false.
If you have CalculateOnBarClose set to true you are effectively not running any logic on the current bar until it has closed. This puts you 1 bar behind which is probably why you are seeing the 6th bar as "invisible".