Hello everyone.
I have noticed that the EA I am working on closes trades if an MT4 is restarted. The issue is that the SL and TP values are lost due to the deinitialisation and logic to close trades gets triggerred on 0 TP values. Could anyone recommend how to store SL, TP and other values used for their calculation (support/resistance lines, etc.) I don't want to send SL and TP values to the broker with the OrderSend.
Recalculation of SL and TP is possible, but I am trying to avoid it if I can. Would storing SL and TP in a file do the trick? Is there any better way as I have had some issues with File operations before.
I appreciate your advice.
R
Place a fake stoploss and takeprofit point that you are managing
those fake points are easie to find when you restart and from that point you get your logic for close on a easie way...
Place a fake stoploss and takeprofit point that you are managing
those fake points are easie to find when you restart and from that point you get your logic for close on a easie way...
Not sure if I understand it correctly. Are you suggesting to send with the OrderSend some fake values (derivatives of the real SL and TP values) and upon restart of the MT4 read them from the broker's server and calculate back the required SL and TP? It can work, I guess, thank you.
Not sure if I understand it correctly. Are you suggesting to send with the OrderSend some fake values (derivatives of the real SL and TP values) and upon restart of the MT4 read them from the broker's server and calculate back the required SL and TP? It can work, I guess, thank you.
Hello everyone.
I have noticed that the EA I am working on closes trades if an MT4 is restarted. The issue is that the SL and TP values are lost due to the deinitialisation and logic to close trades gets triggerred on 0 TP values. Could anyone recommend how to store SL, TP and other values used for their calculation (support/resistance lines, etc.) I don't want to send SL and TP values to the broker with the OrderSend.
Recalculation of SL and TP is possible, but I am trying to avoid it if I can. Would storing SL and TP in a file do the trick? Is there any better way as I have had some issues with File operations before.
I appreciate your advice.
R
Not sure if I understand it correctly. Are you suggesting to send with the OrderSend some fake values (derivatives of the real SL and TP values) and upon restart of the MT4 read them from the broker's server and calculate back the required SL and TP? It can work, I guess, thank you.
If you have an ECN account then it has to be done after placing the trade but if you wanted an invisible Stoploss of 100 pips then you set a stoploss for example 250 pips if pricedifference with your fakestoploss which you can manage is 150 pips you close the trade. If there was a restart needed you simply check your trades and the fakepoints again which can't be lost .....if you modify your trades and your broker is using high stoplevels / freezelevels you can manage the trade closer to your stoplevel with a trailingstop
when opening the order, add SL and TP data to order comment. If MT4 restarts, your order comment will contain the SL and TP values you need, without re-calculating...
If you have an ECN account then it has to be done after placing the trade but if you wanted an invisible Stoploss of 100 pips then you set a stoploss for example 250 pips if pricedifference with your fakestoploss which you can manage is 150 pips you close the trade. If there was a restart needed you simply check your trades and the fakepoints again which can't be lost .....if you modify your trades and your broker is using high stoplevels / freezelevels you can manage the trade closer to your stoplevel with a trailingstop
Yes, with an ECN I will need to do an OrderSend + OrderModify which adds a little bit more room for an error (if OrderModify fails). I am using an OrderReliable, but it doesnt guarantee placing/modifying an order. Perhaps, I will stick to non-ECN brokers for now.
Yes, with an ECN I will need to do an OrderSend + OrderModify which adds a little bit more room for an error (if OrderModify fails). I am using an OrderReliable, but it doesnt guarantee placing/modifying an order. Perhaps, I will stick to non-ECN brokers for now.
trie to code it it isn't that hard if you take the time to code
think what can happen and what do i then have to do....
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone.
I have noticed that the EA I am working on closes trades if an MT4 is restarted. The issue is that the SL and TP values are lost due to the deinitialisation and logic to close trades gets triggerred on 0 TP values. Could anyone recommend how to store SL, TP and other values used for their calculation (support/resistance lines, etc.) I don't want to send SL and TP values to the broker with the OrderSend.
Recalculation of SL and TP is possible, but I am trying to avoid it if I can. Would storing SL and TP in a file do the trick? Is there any better way as I have had some issues with File operations before.
I appreciate your advice.
R