This is the simple strategy that I am using to test the automated trading:
protected override void OnBarUpdate() { if (Position.MarketPosition == MarketPosition.Flat ) { if (Close[1] > Open[1] ) { EnterLongLimit(100, GetCurrentAsk(),""); SetProfitTarget(CalculationMode.Ticks, 30); SetStopLoss(CalculationMode.Ticks,30); } } }
The instrument is QID, an ETF. I am using range bars and testing using the simulated data feed.
The problem is that Close[1] and Open[1] is being calculated for the bar two bars away rather than the bar directly before the current bar, which is being formed.
This is placing the orders one bar late.
For example:
Bar 1 has Close > Open
Bar 2 has Close > Open
The limit order is placed in bar 3 and not bar 2
I would expect the limit order to be placed in bar 2.
I think this is also happening on live data from IB, however I would have to confirm this on Monday when the markets re-open.
Any help/advice appreciated.
Thanks
Chris
Comment