You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Try this , the comments have explainers .
Hello Lorentzos,
Your EA works very well, and it is advance for my level.
I would like to write simple EA trailing stop loss and open new order when order is closed. I wrote one it works well for trailing stop loss but it does not open new order. Can you help me to check why? I think when the condition Orderstotal ()==0 then we can open the new order?
Hello Lorentzos,
Your EA works very well, and it is advance for my level.
I would like to write simple EA trailing stop loss and open new order when order is closed. I wrote one it works well for trailing stop loss but it does not open new order. Can you help me to check why? I think when the condition Orderstotal ()==0 then we can open the new order?
You can simplify it but :
You must open only one order per symbol and keep its ticket
You must retain the ticket of that order in memory
Here you are looping inside open orders so , if your order closes you are not accessing the loop at all
OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
And here this is unlikely , world peace is more possible statistically than the code reaching this point . You are modifying the trail stop and checking if trades are 0 , if trades are zero you have not entered the loop , and , if you have a succesful modification of the trail stop it means you are far from the price by at least trail distance .
And you are sending buy on both occasions
Here is a "simple" version , you should not leave so many things unchecked though
Also if you manually close the order or a margin call occurs or take profit the order will be reopened , the "right after trail stop hits" is not maintainedYou can simplify it but :
You must open only one order per symbol and keep its ticket
You must retain the ticket of that order in memory
Here you are looping inside open orders so , if your order closes you are not accessing the loop at all
And here this is unlikely , world peace is more possible statistically than the code reaching this point . You are modifying the trail stop and checking if trades are 0 , if trades are zero you have not entered the loop , and , if you have a succesful modification of the trail stop it means you are far from the price by at least trail distance .
And you are sending buy on both occasions
Here is a "simple" version , you should not leave so many things unchecked though
Also if you manually close the order or a margin call occurs or take profit the order will be reopened , the "right after trail stop hits" is not maintainedThank very much for your detail explanations.
I tried your EA, it does not trailing stop loss, I checked through the codes, I did not find anything wrong except for slippage you set 1000, I set 0, but it still does not work.
Can you have check again?
Many thanks
Thank very much for your detail explanations.
I tried your EA, it does not trailing stop loss, I checked through the codes, I did not find anything wrong except for slippage you set 1000, I set 0, but it still does not work.
Can you have check again?
Many thanks
It does not have a lastticket to trail , i assumed you had a mechanism that you would plug in to start the trades ,and get the last ticket too .
The slippage is not an issue . 1000 is more likely than 0 in real accounts .
You can start an order on init to test in tester or you can have it search for the manual order and get it's ticket.