_SECTION_BEGIN("NIFTY PAIRS AUTOMATED");
SetChartBkColor(colorBlack);
//initialize params
StartValue = 0;
i=1;
// choose the script whose pairs are to be plotted
script = "NIFTY";
scriptf = script +"-1"; // required to find corresponding future script to find start value automatically
// choose number of pairs required
StepNos = Param("No of Steps",5,3,7,1);
// strike price step selection
step = Param("NIFTY option strike step value",100, 50,100,50);
///// Need to work out automatic startup value depending upon script and last traded price.
// calculating the start value
m = BarCount-1;
g = Foreign( scriptf, "C" );
OptValue = (round(g[m]/100)*100);
//StartValue = Param("Start value", 54.5, 48, 7000, step); // need to automate this value
StepNos = Param("No of Steps",5,3,7,1);
StartValue = OptValue - (floor(StepNos/2) * step );
FinalValue = OptValue + (floor(StepNos/2) * step );
printf(NumToStr(StartValue)+"\n");
printf(NumToStr(FinalValue)+"\n");
Huest = Param("Hue Start", 0, 0, 255, 1) ;
Hueed = Param("Hue End", 255, 0, 255, 1) ;
Huediff = (Hueed - Huest)/ StepNos;
for ( j = StartValue; j <= FinalValue; j=j+step)
{
i=i+1;
k = NumToStr(j,4.0,separator=False);
//
C1 = Foreign( script+k+"C-1", "C" );// change as per broker name
C2 = Foreign( script+k+"P-1", "C" );// change as per broker name
//// for EOD Database Nifty
//C1 = Foreign( scriptf+"_"+k+"_C", "C" );
//C2 = Foreign( scriptf+"_"+k+"_P", "C" );
Clr = ColorHSB(i*Huediff, i*Huediff/3*2, 255) ;
Pair = C1 + C2;
Plot (Pair, "\n"+"Pair"+k, Clr,styleLine);
}
_SECTION_END();