How to execute a trade at the next bar open if Calculate = Calculate.OnBarClose
Could this snippet of code work if i try to open a trade at the next bar open when Calculate = Calculate.OnBarClose ?
If this works, can we assume it will process much faster using this technique than using Calculate = Calculate.OnEachTick and
checking if IsFirstTickOfBar is true if we do a backtest on a large amount of data like a 10 years backtest on a daily chart ?
protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
{
// if MarketDataType == MarketDataType.Last is true and isOkToProcess is true
// then we can theorically assume we are dealing with the next bar open, right ?
if (isOkToProcess && marketDataUpdate.MarketDataType == MarketDataType.Last)
// enter long if the last bar closed higher than the bar before it
if (Close[1] > High[2])
{
EnterLong();
isOkToProcess = false;
}
}