Programm an EA for spread / gap trading

 

Hi,

Lets say we have two instruments that follow the same trend. E.G. Dax and DJ, or WTI and brent.

if there is a certain gap between them, you open long position of the upper and a short position of the lower insturment. Position close when they meet.

Is it possible to program an EA that can do it?

How can an EA meassure the spread between the instruments?

How can an EA close the position?

Best, Sebastian

 
sebastianhh:

Hi,

Lets say we have two instruments that follow the same trend. E.G. Dax and DJ, or WTI and brent.

if there is a certain gap between them, you open long position of the upper and a short position of the lower instrument. Position close when they meet.

Is it possible to program an EA that can do it?

How can an EA measure the spread between the instruments?

How can an EA close the position?

Best, Sebastian

>Is it possible to program an EA that can do it?

Of course it is.

>How can an EA measure the spread between the instruments?

Spread is perhaps an unfortunate choice of terminology but if you can write down the equation of what you want to measure then the computer can calculate it automatically. The job of a trader is work out what the equation or relationship is.

>How can an EA close the position?

By using OrderClose();

https://docs.mql4.com/trading/orderclose


Reason: