Hello!
Somehow my pending trades open immediately in the backtest, and I can't figure out why.
I attached a screenshot where you can see visually: the Entry price is the orange one, the Stop is red, and the TakeProfit is green. Also, you can see the exact value on the Zorro output console. I place the pending order at the first moment of the backtest, and the position should not open immediately; however, it does.
The whole codebase is a huge one; I can't paste it here, but these are the options in the init section:
DLLFUNC void run() {
StartDate = settings.startDate;
EndDate = settings.endDate;
BarPeriod = settings.barPeriod;
asset(settings.asset.c_str());
EntryTime = 5000;
ColorEquity = 0;
ColorDD = 0;
PlotScale = 10;
Spread = Commission = RollLong = RollShort = Slippage = Penalty = 0; //just for research
Hedge = 2;
set(LOGFILE);
set(PLOTNOW);
setf(PlotMode, PL_LONG);
LookBack = SCREENSIZE + 2;
Here is a shortened version of what I am doing to get that screenshot. As you can see, I really plotted those values I am using to open the trade:
Stop = [...calculate stop...];
TakeProfit = [...calculate tp...];
Entry = [...calculate entry...];
printf("\n price: %.5f entry: %.5f stop %.5f tp %.5f", priceClose(0), Entry, Stop, TakeProfit);
plotGraph("sl", impulses[impulseId].startBar, Stop, LINE, RED);
plotGraph("sl", impulses[impulseId].endBar, Stop, LINE | END, RED);
[...the same plot method for all the lines...]
enterShort();
At the moment of trade opening, I saw this in the "Open, Pending, Phantom Trades" window:
- Open: 1.0963
- Price: 1.0963
- Entry: 1.0968
Could you help me point out the settings I should check to activate the pending order possibility?
Thank you!