I've been struggling with this for what seems like forever. I have a very simple strategy that works perfectly fine when run on any chart, using that same chart's data. I want to further refine it by combining it with a lower timeframe.
However, when the lower timeframe chart runs it, using BarsArray[1] to reference the higher timeframe, it always starts off order pending. I run the strategy on the lower timeframe and the voice says "order pending", regardless of whether or not the conditions on the higher timeframe are appropriate for an entry.
The code, when run on a 500 tick chart, referencing no other timeframes, works just fine:
protected override void Initialize() { CalculateOnBarClose = true; } //other stuff if (dsdiff < 1) { if (DoubleStochastics(11).K[0] < 20) { if ( (Position.MarketPosition == MarketPosition.Flat) && (useEntries == true) ) { EnterLong(quantity); SetProfitTarget(CalculationMode.Ticks, ProfitTicks); SetStopLoss(CalculationMode.Ticks, StopTicks); } } }
This code, when run on a 250 tick chart with a secondary timeframe of 500 ticks initialized as BarsArray[1], starts off "order pending" regardless of the conditions:
protected override void Initialize() { CalculateOnBarClose = true; Add(PeriodType.Tick, 500); // BarsArray[1] } //other stuff, identical to the above if (dsdiff < 1) { if (DoubleStochastics(BarsArray[1], 11).K[0] < 20) { if ( (Position.MarketPosition == MarketPosition.Flat) && (useEntries == true) ) { EnterLong(quantity); SetProfitTarget(CalculationMode.Ticks, ProfitTicks); SetStopLoss(CalculationMode.Ticks, StopTicks); } } }
What am I missing here?
Thanks in advance,
Gary
Comment