I'm developing a strategy on 5 Minutes bars as primary and I'm adding 60 minutes bars for trend validation.
However, I've noticed that when I download Market Replay data (Level 1) and run my strategy over it, I get the same values all the time on my 60 minutes bars.
I'm testing the 60 bars on every tick on my 5 minutes bar.
I've also tried to test the 60 minutes bars only when BarsInProgress == 1... same result.
my code looks like:
protected override void Initialize()
{
Add(PeriodType.Minute, 60);
CalculateOnBarClose = false;
}
protected override void OnBarUpdate()
{
if(BarsInProgress != 0) return;
try
{
bool? isUp = CheckTrend();
...
}
catch(Exception ex)
{
...
}
}
private bool? CheckTrend()
{
return CheckTrend(0);
}
private bool? CheckTrend(int index)
{
if(index+1 >= Highs[1].Count) return null;
bool isUp = Highs[1][index] > Highs[1][index+1];
bool isDown = Lows[1][index] < Lows[1][index+1];
Print(string.Format("high[0]: {0}, high[1]: {1}, low[0]: {2}, low[1]: {3}", Highs[1][0], Highs[1][1], Lows[1][0], Lows[1][1]));
if(isUp && isDown) return null; // Current bar broke up & down
if(!isUp && !isDown) // Current bar is inside bar
{
return CheckTrend(index+1);
}
return isUp; // Current bar broke either up or down the previous bar
}
Regards,
Eyal.


Comment