Download MetaTrader 5

Check Closed Losing Trades to reenter

To add comments, please log in or register
Don De Rota
69
Don De Rota  

Hi

How can I check orders that have executed and closed with a loss? I use pending stop orders to enter trades.

I want to check closed orders and if they were losers and price is now below my entry price (long eg) I want to place

the same pending stop order and give it another go. I would like the option to reenter the same losing trade several

times if I want too or only once.

It might only be one losing trade or many losing trades that I want to reenter.

I know I have to run it though the standard loop but struggling with the method and logic to do the above.


Thanks in advance

Keith Watford
Moderator
10619
Keith Watford  

You could use external variables to input the type, entry, SL and TP. Also unique magic number.

Then have the EA open the pending order and save the ticket number as a Global variable.

After that you can select the order (use SELECT_BY_TICKET, no need for a loop) and check whether it is closed (OrderCloseTime!=0) and whether it closed at a profit or loss.

If it closed at a loss, send a new order using the same extern variables and assign the new ticket number to the same Global variable.

You will also need a counter so that you can limit the amount of times that the order is repeated.

To add comments, please log in or register