In backtesting (NT 7), the trade is not always consummated, although it of course always happens in the real world. I use GetCurrentBid as the bar price for buy orders and GetCurrentAsk as the sell price for sell orders. I don't care if the EMA crosses the Bid, the Ask, or the Last, as long as it crosses some part of the price bar. It would seem to me that using the bid price on a buy and the ask price on a sell would capture the cross no matter where in the bar it occurred.
I was wondering if I'm coding this wrong or if my problem is a function of the backtest engine. This is being tested on an intraday range chart.
Here is relevant code:
if (EMA(10)[0] > EMA(20)[0]
&& GetCurrentBid()<= EMA(10)[0])
{
EnterLong(DefaultQuantity, "10Long");
}
Comment