EA based on the movement of another pair

 

I'm testing a lot of correlations lately and I would like to possibly automate my trades using EAs.

 What I'm trying to do is if a certain currency pair moves by 100pts on the M1 chart, I will be entering a trade on a different but correlated currency pair.

 In terms of programming, I have already placed input parameters that are required (lot size, stop loss, take profit).

 What I'm actually missing is the part where I get to compute the reference currency pair's movement. I've checked iCustom but it requires a custom indicator. CopyHigh seems like the option but I'm not sure if it can do realtime processing (as mentioned, the EA will only base its decisions on the M1 chart, so every second counts). Can someone guide me to the right function?

 
Winterburn:

I'm testing a lot of correlations lately and I would like to possibly automate my trades using EAs.

 What I'm trying to do is if a certain currency pair moves by 100pts on the M1 chart, I will be entering a trade on a different but correlated currency pair.

 In terms of programming, I have already placed input parameters that are required (lot size, stop loss, take profit).

 What I'm actually missing is the part where I get to compute the reference currency pair's movement. I've checked iCustom but it requires a custom indicator. CopyHigh seems like the option but I'm not sure if it can do realtime processing (as mentioned, the EA will only base its decisions on the M1 chart, so every second counts). Can someone guide me to the right function?

Hello Winterburn, welcome to the MQL5 forum!!

I think you have to use CopyRates() instead of CopyHigh(). You can select not only the symbol you want, but also the timeframe to get the quotes.

 
Winterburn:

I'm testing a lot of correlations lately and I would like to possibly automate my trades using EAs.

 What I'm trying to do is if a certain currency pair moves by 100pts on the M1 chart, I will be entering a trade on a different but correlated currency pair.

 In terms of programming, I have already placed input parameters that are required (lot size, stop loss, take profit).

 What I'm actually missing is the part where I get to compute the reference currency pair's movement. I've checked iCustom but it requires a custom indicator. CopyHigh seems like the option but I'm not sure if it can do realtime processing (as mentioned, the EA will only base its decisions on the M1 chart, so every second counts). Can someone guide me to the right function?

Note that most of the functions that work with symbols have a parameter to define the name of the symbol, regarding the information you want about it.

And the most relevant: the graph that your EA is running (for any symbol) don't change this rule.

The only problem you will have is about synchronize ticks and events of the two pairs, as you must select one to run your EA thread, so be aware to use OnTimer if you don't want to wait the graph symbol ticks and have a better control about that.

About the reference symbol, you just need to adjust the functions you already use for the main symbol and set the reference symbol name in the parameters.

Simple as that.

Reason: