Hello, I am getting some errors in live trading that I don't get in Zorro's backtest. I think it must be something to do with Zorro's interaction with the broker, but I hope that someone can shed some light on what's going on.
I have a strategy that performs reasonably well in backtesting, but when I trade it via Zorro's MT4 bridge, some of the exits are not honoured. I am using a Stop and Trail condition, and I am also using the exitLong and exitShort functions to exit a trade when a crossOver/crossUnder condition is met.
The Stop and Trail functions work fine in both testing and live trading, however the exitLong/Short functions behave differently in testing and trading. I get the following general error in Zorro's message window, and the log file:
[EUR/USD <trade ID>] can't close x@price at time
I also get error messages in MT4's 'Experts' tab.
As a specific example, at time 08:35, I get the following messages in MT4's 'Experts' tab:
Zorro EURUSDpro,H4: Close[EURUSDpro:S87]-0.01@1.2688
Zorro EURUSDpro,H4: invalid lots number for OrderClose function
Zorro EURUSDpro,H4: close@1.2688 failed - invalid function parameter value
Here are the messages from Zorro's log file from the same time:
[Mon 29.09. 08:30] 5124 -302 +7 !
[Mon 29.09. 08:35] 5124 -302 +6 !
[EUR/USD::S0087] Can't close 1@1.2688 at 08:35
This is the code that uses the exitLong/Short condition:
if (NumWinningLong > 0 and crossUnder(SmoothPrice, Decycler))
exitLong();
if (NumWinningShort > 0 and crossOver(SmoothPrice, Decycler))
exitShort();
I'm not sure, but it seems to me that Zorro is trying to exit the trade at a certain price when the exitLong/Short condition is met. My intention is to exit the trade at market when this condition is met, hence the omission of any parameters inside the exitLong/Short function. From the manual:
'Optional parameters can be omitted. F.i. exitLong() exits all long positions with the current asset and algorithm identifier at market."
I get the feeling that I am missing something important here. Can anyone suggest a solution or point me in the right direction?
Thanks in advance.