Need some help for my EA

 

Hello,


For the last 6 months I'm working on my own EA, and so far it is working quite good, but sometimes I get trades like this:

255 2009.01.20 19:36 s/l 40 0.10 1.2910 1.2910 0.0000 1.00 810.52
256 2009.01.20 19:36 sell 41 0.10 1.2908 0.0000 0.0000 0.00 810.52


So an order hits the S/L, and then directly opens a new trade. Sometimes it will close in profit but an other time it hits my S/L.

My EA is working with some indicators and trailing, now I have an idea to solve that problem what I have, but I have no idea how to program that.


My idea to solve this, is to have a counter that starts always at 0 and when there is an open trade this will go to 1.

But now it comes, I have in my EA that it is not possible to open a second trade in the same bar as the order opened. (This is working like I say in the sentence above)

Now I want that it is not possible that there will be a new trade opened in the bar where a trade closed, but waits for lets say 2 new bars until it will check if there is a new opportunity to open a new trade.


Someone here that can make this code for me? I think that it is quite simple but I have no clue how to do this.


Thanks in advance.

 

If a simple variable with 1 or 0 isnt enough, use a datetime variable and put in the time when you enter and exit trades. With a real time value, you'll be able to calculate if it's been long enough to reopen one.

Jon

Reason: