Thank you for your answer. Put very simply, my problem is that Zorro closes trades at prices below the low of the candle (see the attached image) (the bar that I referred to is a bar or candle on a normal technical analysis price chart, so it also has an open, high, low and close. The range that I referred to is the range between the low and the high price).
I reread the manual pages that you referred to and made a simpler example to illustrate the problem, I have included the code below and attached an image of the result. Notice how the trade closes at a price below the low of the day on 2018-05-22. This only seems to happen for "take profit" orders and not for "stop loss" or "entry" orders (e.g. the entry on 2018-05-21 and the stop loss on 2018-05-31 are filled at the open of the day). From my understanding of the manual when Fill=3, "take profit" orders should also fill at the open of the day. Is this a bug in Zorro or have I misunderstood something?
function run()
{
StartDate = 20180511;
EndDate = 20180713;
BarPeriod = 1440;
LookBack = 160;
set(LOGFILE,PLOTNOW);
assetList("AssetsSP250y.csv");
asset("MU");
vars Lows = series(priceLow());
vars Highs = series(priceHigh());
Fill=3;
PIP=0.01;
if (Bar==200 || Bar==206) {
var entryPrice=Highs[0]+PIP;
var stop=Lows[0]-45*PIP;
var rr=1.2; // reward/risk
var target=(1+rr)*entryPrice-rr*stop;
enterLong(1, entryPrice, stop, target);
}
}