This topic does not
represent financial investing or trading advice -- it is merely ideas
I have been looking at and wanting to put into a functional EA.
Pairs that are
highly correlated (always move in same direction) sometimes go
slightly out of correlation, but long term will get back in
When this happens,
the idea is to sell the higher priced pair, and buy the lower priced
pair, creating a crude hedge. Over time the correlation mismatch
closes up, and the EA will take profit.
Pick 2 correlating
Calculate long term
simple moving average (I currently use 52 weeks) .
current price as a percentage of the long term SMA.
Calculate the percentage difference between the previous time period and the current time
period to get a percentage change.
If large enough
percentage difference between the pairs, Sell the higher priced pair,
Buy the lower price pair. (current using 1 microlot)
Check every 3
seconds for a profit on the account. If at profit level, close all
With the attached EA
code, I have a number of problems:
positions are opened on one side (say buy side) but none on the sell
side. I cant figure what is wrong with the logic. A bit tricky to
test this historically, as MT4 only allows you to test with one
currency pair. I have run this against a demo account.
Any assistance or
As I am not a coder so I can provide a standard reply only sorry :
I just hope someone will help.
The problem is probably here: