Stop trading when losing, but how to come back to market?

 

Hi all!

I would like to change my EA so that after X number of losing trades it would stop trading, and then after Y trades that *would* have been winning ones, it would continue again. It is of course easy the check if previous trades were losing ones and stop the trading, but how could I implement the method for enabling the trading again?? I mean; since the EA is not trading, I cannot check for previous trades, so I think that I should somehow emulate the trading method against stoploss & take profit levels. But is there any "easy" way to do it..?

All hints are highly appreciated :=)

 
AlliumPorrum:

Hi all!

I would like to change my EA so that after X number of losing trades it would stop trading, and then after Y trades that *would* have been winning ones, it would continue again. It is of course easy the check if previous trades were losing ones and stop the trading, but how could I implement the method for enabling the trading again?? I mean; since the EA is not trading, I cannot check for previous trades, so I think that I should somehow emulate the trading method against stoploss & take profit levels. But is there any "easy" way to do it..?

All hints are highly appreciated :=)

You answered your own question. There is no easy way, you have to emulate the trades.
 
Alain Verleyen:
You answered your own question. There is no easy way, you have to emulate the trades.

Ok, thanks. So there isn't any possibility in MT4 to open "0 lot trades" etc. just for testing purposes?

If I have to manually emulate my trades, can you give any ideas on what would be the best way to do it? Should I basically just store the TP and SL levels on some arrays, and then on every tick check if the price did hit any of them. If it did, then store the win/loss information into the third array, and remove the values from SL & TP arrays. Or what?

 
AlliumPorrum:

Ok, thanks. So there isn't any possibility in MT4 to open "0 lot trades" etc. just for testing purposes?

No (by the way I already answered).

If I have to manually emulate my trades, can you give any ideas on what would be the best way to do it? Should I basically just store the TP and SL levels on some arrays, and then on every tick check if the price did hit any of them. If it did, then store the win/loss information into the third array, and remove the values from SL & TP arrays. Or what?

Something like that, yes. A structure will be simpler to manage though.

struct order_structure
  {
      double sl;
      double tp;
      //...
  }myOrders[];
 
Ok, thanks! If I create a struct for each trade, what would be the best container for all these structs, so that it would be easy to add, remove, and search for them etc.? An "array" of these structs, or what? (This might be a dump question, but I'm not so familiar with data handling in MT4...)
 
AlliumPorrum:
Ok, thanks! If I create a struct for each trade, what would be the best container for all these structs, so that it would be easy to add, remove, and search for them etc.? An "array" of these structs, or what? (This might be a dump question, but I'm not so familiar with data handling in MT4...)
The code excerpt I provide you is declaring an array of struct. Up to you now ;-)