_SECTION_BEGIN("Background_Setting");
SetChartBkGradientFill( ParamColor("BgTop", colorBlack),
ParamColor("BgBottom", colorDarkGrey),ParamColor("TitleBack",colorGrey40));
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
SetChartOptions(0,chartShowArrows|chartShowDates);
_SECTION_END();
_SECTION_BEGIN("Candle color");
upbar= H > Ref(H,-1) AND L > Ref(L,-1);
dnbar= H < Ref(H,-1) AND L < Ref(L,-1);
SetBarFillColor(IIf(upbar,ParamColor("Candle UP Color", colorGreen),IIf(dnbar,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
Plot(C,"Close",IIf(upbar,ParamColor("UP Color", colorDarkGreen),IIf(dnbar,ParamColor("Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
_SECTION_END();
_SECTION_BEGIN("Breakout Setting");
Buyperiods=Param("Long Brkout pds ",5,1,100,1,1);
Sellperiods=Param("Short Breakout pds",5,1,100,1,1);
Buy = C> Ref( HHV(H,Buyperiods), -1 ) ;
Sell= C < Ref(LLV(L,Sellperiods),-1) ;
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), 43, layer = 0,yposition = Low, offset = -20);
PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorRed, layer = 0, yposition = High, offset = -20); //shapeSmallCircle
GraphXSpace=10;
_SECTION_END();
_SECTION_BEGIN("VSTOP ");
// VSTOP&ATR
// E.M.Pottasch, Jul 2010
// from Metastock formula, link: http://stocata.org/metastock/stop_trail_atr.html
// added separate parameters for upward and downward market environment
function vstop_func(trBull,trBear)
{
trailArray[ 0 ] = C[ 0 ]; // initialize
for( i = 1; i < BarCount; i++ )
{
prev = trailArray[ i - 1 ];
if (C[ i ] > prev AND C[ i - 1 ] > prev)
{
trailArray[ i ] = Max(prev,C[ i ] - trBull[ i ]);
}
else if (C[ i ] < prev AND C[ i - 1 ] < prev)
{
trailArray[ i ] = Min(prev,C[ i ] + trBear[ i ]);
}
else if (C[ i ] > prev)
{
trailArray[ i ] = C[ i ] - trBull[ i ];
}
else
{
trailArray[ i ] = C[ i ] + trBear[ i ];
}
}
return trailArray;
}
VSTOPATRper = Param("VSTOPper",14,1,50,1,0) ;
Res = Param("VSTOPMultRes",2,1,10,0.1,0) ;
Sup = Param("VSTOPMultSup",2,1,10,0.1,0) ;
trBear = res * ATR(VSTOPatrper);
trBull = sup * ATR(VSTOPatrper);
trailArray = vstop_func(trbull,trbear);
tsz=0.05;uu=(1/tsz);
trailArray=round(trailArray * uu)/uu;
Plot(trailArray,"\nVSTOP",colorGrey50,styleLine|styleThick) ;
bc = BarCount;
lineSL = trailArray;
StartXre = LastValue( ValueWhen( lineSL, 1 ) );
EndYre = LastValue( ValueWhen( lineSL, lineSL ) );
PlotText( "Tr.SL. = " + NumToStr(EndYre,1.2) , bc + 1, EndYre , colorWhite, colorBlue);
_SECTION_END();
_SECTION_BEGIN("Title");
Dates = DateTime();
Title = EncodeColor(colorWhite)+"Trading System Ver 1.0 [ Subroto ~ 29/03/2013 ] " + "\n"+ Name () + " / "
+EncodeColor(colorWhite) + Date() + " , "+ Interval(2)+"\n"
+EncodeColor(colorWhite)+ "Open ~ "+ EncodeColor(colorWhite)+ O + " | "
+EncodeColor(colorWhite)+ "High ~ "+ EncodeColor(colorWhite)+ H + " | "
+EncodeColor(colorWhite)+ "Low ~ "+ EncodeColor(colorWhite)+ L + " \n"
+EncodeColor(colorWhite)+ "Close ~ "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorGold))+ C + " | "
+EncodeColor(colorWhite)+ "Change ~ INR "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorGold)) + WriteVal(C-Ref(C,-1),1.2)+" ."
+EncodeColor(colorWhite)+ " / "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorGold))+ WriteVal( ROC( C, 1 ),1.2)+""+ " % "
+EncodeColor(colorWhite)+ "\nVolume : " + EncodeColor(colorWhite)+ NumToStr(V,1.0)+ "\n\n"
+EncodeColor(colorBrightGreen)+ "Last Buy was on = " + WriteVal(ValueWhen(Buy, Dates, 1), formatDateTime)+" \n@ Rs."+ WriteVal(BuyPrice,1.2)+"\n\n"
+EncodeColor(colorYellow)+ "Last Sell was on = " + WriteVal(ValueWhen(Sell, Dates, 1), formatDateTime)+" \n@ Rs."+ WriteVal(SellPrice,1.2)+"\n\n";
_SECTION_END();