At some bars, I am supplying an absurd value for Margin, via
Margin = OptimalFLong * Capital * sqrt(1 + ProfitClosed / Capital);
or
Margin = OptimalFShort * Capital * sqrt(1 + ProfitClosed / Capital);
this comes out as -INF when ProfitClosed is less than -Capital.
Zorro does not complain and instead behaves bizarrely.
I guess it is my fault for supplying a bad Margin.
It would be nice if Zorro complained in a more visible and directed way in case of invalid trade parameters.
Note that if you set Margin to 0, or a finite negative number, Zorro does the sensible thing and does not enter a trade. But if Margin is -INF, it does enter a trade or do something weird.
Demo:
function run() {
BarPeriod = 399;
LookBack = 273;
StartDate = 20140101;
EndDate = 20140401;
set(TICKS);
ExitTime = 3;
Capital = 4500;
var atrx = ATR(232);
Stop = 1.0 * atrx;
TakeProfit = 1.5 * atrx;
Margin = sqrt(-1);
enterLong();
}
Expected:
No trades when Margin is not a finite positive number.