EA closing trades using wrong chart's information

 
Hey all,

I have an EA running on a GBP 30 minute chart, and also one that works on the same parameters on the 15 and 5M charts. In my forward testing, I am noticing the 30M chart will open a trade, and then use the 15 minute chart's techs to close. Or, when it is time to close a sell order, it will open a new buy order while simultaneously closing the sell. It seems it is all crossing over. I am using Magic Numbers, but it still seems to keep doing it. Anyone know what it happening?? Thanks!

Matt
 
You'll need different magic's for for the different time frames and the expert will need to filter all orders to match only it's own magic (when looking through the list of orders).

Try something like

#define MAGICMA (10000 + Period())


Markus
 
Markus,

Thanks very much for the help. However, I tried it and got an error. It said something like "value expected". Did I do something wrong? Thanks again.

Matt
 
Matt,

sorry, I had just typed it here ... doesn't seem to work with #define.

try it like this:

delete the #define MACIGMA command.

add:
int MACGICMA= 10000;


then in the init function (not start(!) function) write:

MACIGMA= 10000+ Period();


This should give you different magics for trades in different time frames. Make sure that you are checking for a match on macgic and symbol whenever you select an order for trailstop, closing, etc.


Markus
 
Markus,

Thanks very much for your help!! I think I got it fixed already. I just made sure that no currency has the same EA on different time frames, and that each has its own Magic Number. So far, so good, with no weird trades taking place. Once again, though, thanks for all your help. :)

Matt
Reason: