You are on page 1of 2

_SECTION_BEGIN("Spread RSI");

// Enter the Variables Here


Mkt = ParamStr("High Priced Scrip", "Enter High Priced Scrip Here");//Enter the
High Priced Scrip of the Pair as per the NSE Nomenclature or the nomenclature se
t by the Data Provider, by right clicking the mouse and selecting 'Parameters'.
SprPer1=Param("Period - Fast Spread RSI", 8, 2, 1000, 1);//Enter the required Pe
riod for the calculation of Spread by selecting 'Parameters'. Default SprPer1 =
8
SprPer2=Param("Period - Slow Spread RSI", 21, 2, 1000, 1);//Enter the required P
eriod for the calculation of Spread by selecting 'Parameters'. Default SprPer2 =
21
//***Base Market************/
P=Foreign(Mkt,"C");//Closing Price of High Priced Scrip Entered Above
/***Spread******************/
Spr=P-C;//Spread of Scrip A & Scrip B (Difference of Closing Price of Scrip A &
Scrip B)
/***Spread RSI**************/
Chg = Spr - Ref(Spr,-1);
Up = IIf( Chg > 0, Spr - Ref( Spr, -1), 0);
Dn = IIf( Chg < 0, abs( Spr - Ref( Spr, -1)), 0);
// (Max(Spr, Ref( Spr, -1)) - Min(Spr, Ref( Spr, -1))) // This can also be used
instead of ABS function
UpMov8 = EMA( Up, 8);
DnMov8 = EMA( Dn, 8);
RS8 = IIf( DnMov8 == 0, 100000, (UpMov8 / DnMov8));
RSISpr8 = 100 - ( 100 / (1 + RS8));
Plot( RSISpr8, "Fast Spread RSI ("+ int(SprPer1) + ")", ParamColor("Color - Fast
Spread RSI", colorBlue ), ParamStyle("Style - Fast Spread RSI") );
UpMov21 = EMA( Up, 21);
DnMov21 = EMA( Dn, 21);
RS21 = IIf( DnMov21 == 0, 100000, (UpMov21 / DnMov21));
RSISpr21 = 100 - ( 100 / (1 + RS21));
Plot( RSISpr21, "Slow Spread RSI ("+ int(SprPer2) + ")", ParamColor("Color - Slo
w Spread RSI", colorViolet ), ParamStyle("Style - Slow Spread RSI") );
Plot(70,"",colorRed,styleThick);
Plot(30,"",colorGreen,styleThick);
Plot(50,"",colorBlack,styleThick);
Plot(55,"",colorTeal,styleThick);
Plot(45,"",colorCustom12,styleThick);
Title=EncodeColor(colorCustom12)+
WriteIf(P>C,"High Priced Scrip is " +EncodeColor(colorBlue)+"'"+StrFormat(Mkt)+"
'"+EncodeColor(colorBlack) +" AND "+
EncodeColor(colorCustom12)+"Low Priced Scrip is " +EncodeColor(colorBlue)+"'"+Na
me()+"'",
"High Priced Scrip is " +EncodeColor(colorBlue)+"'"+Name()+"'"+EncodeColor(color
Black) +" AND "+
EncodeColor(colorCustom12)+"Low Priced Scrip is " +EncodeColor(colorBlue)+"'"+St
rFormat(Mkt)+"'") +EncodeColor(colorBlack) +" | "+
EncodeColor(colorCustom12)+"Spread RSI (" + int(SprPer1) + ") : " +EncodeColor(c
olorBlue)+WriteVal( RSISpr8, format=1.2) +EncodeColor(colorBlack) + " | "+
EncodeColor(colorCustom12)+"Spread RSI (" + int(SprPer2) + ") : " +EncodeColor(
colorViolet)+WriteVal( RSISpr21, format=1.2) +EncodeColor(colorBlack);
_SECTION_END();

You might also like