In my trading system with long positions, probacktest sometimes executes the order better like “buy 1 share at close stop” and other times it is more correct “buy 1 share at close limit” depending on whether there is a bullish or bearish gap.
Is it possible to tell probacktest to choose the option closest to the closing price when the conditions are met? I have tried to put the two options, but then open two positions and I just want you to open one.
All decisions are made at the close of a candle and orders placed at the opening of the next one so once a new candle opens it is too late to change anything or make any decisions based on this candles opening price.
Use IF to compare prices and place the correct pending order.
But if I understand correctly the OP wants to make that decision based on the gap to the next candle which is not known until that candle opens and then it is too late to place any orders.
Entering AT CLOSE is a bit awkward, ’cause when the candle closes and conditions are met maybe a tenth of a pip has already moved up or down (ot there can be a GAP) and CLOSE might be slightly away from that price and you cannot tell whether you have to place a LIMIT or STOP order.
As Vonasi said, it is impossible to predict a GAP, so I suggest to use AT MARKET, instead.