Creating a Spread Indicator

 

Hi all!

I just want to create a spread signal based on two CFD's. This signal will be calculated as: Close(CFD_1) - Close(CFD_2).

How can I get a Spread [Pos] = Close [Pos] (for CFD_1) - Close [Pos] (for CFD_2)? I don't know how to get the Close[Pos] info for a different Timeseries the indicator is in.

Thank you in advance!

 

Spread[Pos] = iClose("CFD_1",time_frame,Pos)- iClose("CFD_2",time_frame,Pos);

...


"time_frame" can be a value from {NULL, PERIOD_M1, PERIOD_M5, ..., PERIOD_MN1}. Assigning NULL, indicator assumes current chart's timeframe.

 
Thanks guy!