Manual intervention on MT5

Posted By: jacqu

Manual intervention on MT5 - 10/04/22 07:16

Hi

I use Zorro code to help with discretionary trading on a MT5 platform. It enters a trade under certain conditions and places a stop after which I manage the trade manually in MT5.
If I close the trade myself in MT5 Zorro states 'can't close at attempt x'. The MT5 experts log states 'Trade x not found..'.

It is a NON NFA compliant account, TICKS is set and Hedge=1. Using Zorro S.

It seems I must use cancelTrade() ?. The manual states ‘useful for removing an externally closed position that was not transmitted to Zorro..’

Must cancelTrade() be used in an enumeration loop within a TMF?
What condition/code is used to establish whether the trade has been closed externally?

Zorro does also not recognize if I move the stop myself in MT5. How does one code this?

Thanks..


Posted By: jcl

Re: Manual intervention on MT5 - 10/04/22 12:53

If you move the stop in MT5, Zorro should not manage it at all. Otherwise both stops will interfere.

MT4 reports back to Zorro when a trade was manually closed, but not MT5. If Zorro is only used for opening the trade, but not for managing it, simply call cancelTrade directly after opening it.

TRADE* Trade = enterLong();
if(Trade) cancelTrade(Trade);
Posted By: jacqu

Re: Manual intervention on MT5 - 10/04/22 14:11

Many thanks JCL...
Posted By: jacqu

Re: Manual intervention on MT5 - 10/06/22 06:16


I still need Zorro to manage trades up to the point that I decide to close a trade.

If MT5 does not report back to Zorro about a closed trade is there some functionality or condition/code that can be used in Zorro to establish this?

Thanks..
Posted By: Grant

Re: Manual intervention on MT5 - 10/06/22 08:59

You can use for(closed_trades) or one of the other loops, see https://zorro-project.com/manual/en/fortrades.htm (examples below)
Posted By: jcl

Re: Manual intervention on MT5 - 10/06/22 14:53

You could theoretically evaluate some trade variable, like the TradeProfit, and if it does not change over a certain time during market hours, assume that the trade was closed. But that would be a wobbly solution and I do not recommend it.

It is possible to let MT5 report a closed trade. But it requires more complex code than with MT4, which is one of the many reasons why all prefer MT4 over MT5. We had not implemented this because the demand did not come up yet. But I'll see if we can implement it in one of the next Zorro versions. Until then, your best solution is probably a script function that callis cancelTrade on a button click with a user panel.
Posted By: jacqu

Re: Manual intervention on MT5 - 10/07/22 08:55

Thanks Grant & JCL for the feedback, much appreciated.

The main reason for using MT4 vs MT5 are the different timeframes outside of the 1H and 4H which MT5 offer; they work better as triggers under certain conditions/indicators and from a semi automated/discretionary trading perspective one needs the 'visual confirmation' on a similar timeframe as your code to know that things are going according to plan.

I see there are ways to implement alternative timeframes in MT4, don't know how successful they are; will look into it and if OK will then rather use MT4.

JCL if I understand you correctly a 'for(closed_trades) loop or for that matter no existing Zorro conditional code will work without having received the external trigger of a manually closed trade from MT5?

Look forward to having the functionality in MT5.

Thanks again..
© 2024 lite-C Forums