Combined Bands Model trades

#4
In This thread I will post model trades based on Various EMA bands .

The purpose of posting the trades is discussion on trades to make the concepts & trades more clear.

Hope ST Sir, Pratap Sir & other seniors will guide me time to time & help me in understanding the concepts.
Good Initiative . :thumb:

It would be good if you could give a brief summary of your decision making about the trades taken or potential trades.
 

Gaur_Krishna

Well-Known Member
#7
Good initiative Vikas. Along with entry & exit, plz share the AFL. I am aware that its available in Pratap's thread still if you share the same, we all will be on same page.
We know your favorite is BNF, looking forward

All the best.....

Regards,
Gaur_Krishna
 

VIKAS 21

Well-Known Member
#8
_SECTION_BEGIN("HighVol");
SetChartOptions(0,chartShowArrows|chartShowDates|chartWrapTitle);
SetChartBkColor(ParamColor("Background", colorLightGrey)) ;

useforeign = ParamToggle("Set Foreign", "No|Yes", 0) ;
List = GetCategorySymbols(categoryMarket, 0) ;
forscript = ParamList("Scrip", List, 0) ;
if (useforeign)
SetForeign(forscript);

settf = ParamToggle("Set TF", "No|Yes", 0) ;
tf = Param("TF", 5, 1, 100000, 1) ;

if (settf)
{
SetChartOptions(3,chartShowDates);
TimeFrameSet(tf*in1Minute) ;
}

Layer = Param("Layer", 0, -5, 5, 1) ;
if (settf)
tz = NumToStr(tf, 8.0) +"-minute";
else
tz = NumToStr(Interval()/in1Minute, 8.0) +"-minute";
//_N(Title = StrFormat(Name() + " " +tz + " " + NumToStr(ddt, formatDateTime) + " Range %g {{VALUES}}", SelectedValue( dh-dl) ));
_N(Title = StrFormat(Name()+tz+ NumToStr(DateTime(), formatDateTime)+ EncodeColor( colorGreen ) + " Open %g," + EncodeColor( colorBlue ) + " Hi %g, " + EncodeColor( colorRed ) + " Lo %g, " + EncodeColor( colorBlack ) + " Close %g (%.1f%%){{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", colorBlack, styleNoTitle | styleCandle,0,0,0,Layer );
ToolTip = "Open = " + O + "\nHigh = " + H + "\nLow = " + L + "\nClose = " + C ;

if (settf)
{
Daych = Day() != Ref(Day(), -1) ;
Plot(IIf(Daych, 100, 0), "", colorBlack, styleHistogram|styleNoLabel|styleOwnScale, 0, 100, 0, -5) ;
}
//Peaking Volumes
HiVolume = IIf(V > (2 * MA(V,10)), True, False);
PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);
//TimeFrameRestore()
_SECTION_END();

_SECTION_BEGIN("pratap's 2day vwap");
SetChartOptions(2,chartWrapTitle);
SetChartBkColor(ParamColor("Background", colorLightGrey)) ;
// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
/*
The VWAP for a stock is calculated by adding the dollars traded for every
transaction in that stock ("price" x "number of
shares traded") and dividing the total shares traded. A VWAP is computed
from the Open of the market to the market Close, AND is
calculated by Volume weighting all transactions during this time period

*/
Layer = Param("Layer", 0, -5, 5, 1) ;
showprice = ParamToggle("Show Price", "No|Yes", 0) ;
if (showprice)
{
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} " + EncodeColor( colorGreen ) + " Open %g," + EncodeColor( colorBlue ) + " Hi %g, " + EncodeColor( colorRed ) + " Lo %g, " + EncodeColor( colorBlack ) + " Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", colorBlack, styleNoTitle | styleCandle,0,0,0,Layer );
//Peaking Volumes
HiVolume = IIf(V > (2 * MA(V,10)), True, False);
PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);
ToolTip = "Open = " + O + "\nHigh = " + H + "\nLow = " + L + "\nClose = " + C ;
}

farback = Param("Far Back", 500, 1, 10000, 1) ;
SetChartBkColor(colorLightGrey) ;
useforeign = ParamToggle("Set Foreign", "No|Yes", 0) ;
//List = GetCategorySymbols(categoryMarket, 0) ;
//forscript = ParamList("Scrip", List, 0) ;
forscript = ParamStr("Scrip", "NIFTY_F1") ;
if (useforeign)
SetForeign(forscript);

ndays = Param("N Days", 5, 1, 10000, 1) ;
turnvwapoff = ParamToggle("VWAP All OFF", "No|Yes", 0) ;
showintitle = ParamToggle("Show in Title", "No|Yes", 0) ;
Filterdaych = ParamToggle("Filter Day Change Connections", "No|Yes", 1) ;

Vwapmode = ParamList("VWAP mode", "As Per Param|Only VWAP|VWAP+SD|VWAP+2SD", 0) ;
showvwap = ParamToggle("Show VWAP", "No|Yes", 1) ;
showvwap1sd = ParamToggle("Show VWAP 1SD", "No|Yes", 1) ;
showvwap2sd = ParamToggle("Show VWAP 2SD", "No|Yes", 1) ;
showvwap3sd = ParamToggle("Show VWAP 3SD", "No|Yes", 0) ;
showvwapband = ParamToggle("Show VWAP Trend Bands", "No|Yes", 1) ;
showvwapswband = ParamToggle("Show VWAP Sideways Bands", "No|Yes", 0) ;
showprevdayvals = ParamToggle("Show Prev Day Values", "No|Yes", 1) ;
showprev2dayvals = ParamToggle("Show Prev 2 Day Values", "No|Yes", 1) ;
showprevdayband = ParamToggle("Show Prev Day Bands", "No|Yes", 0) ;
showextprevday = ParamToggle("Show Extension", "No|Yes", 1) ;
showextbandprevday = ParamToggle("Show Extension Band", "No|Yes", 1) ;
extend = Param("Extend", 20, 0, 100, 1) ;


Vwaplayer = Param("VWAP Layer", -3, -5, 5, 1) ;
extlayer = Param("Extend Layer", -2, -5, 5, 1) ;

MAwidthper = Param("MA Width %", 0.005, 0, 10, 1) ;
SDwidthper = Param("SD Width %", 0.005, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
SDwidth = SelectedValue(C) * SDwidthper /100 ;


showtradearr = ParamToggle("Trade Arrow", "No|Yes", 1) ;

showtext = ParamToggle("Show Text", "No|Yes", 1) ;
Clrtext = ParamColor("Color Text", colorBlack) ;
showvahvaltext = ParamToggle("Show VAH-VAL Text", "No|Yes", 1) ;

Onlyvwap = False ;
withsd = False ;
with2sd = False ;

switch (Vwapmode)
{
// case "As Per Param":
// break ;
case "Only VWAP" :
Onlyvwap = True ;
break ;
case "VWAP+SD" :
Onlyvwap = True ;
withsd = True;
break ;
case "VWAP+2SD" :
Onlyvwap = True ;
withsd = True;
with2sd = True;
break ;
}

if (Onlyvwap)
{
if (withsd)
showvwap1sd = True;
else
showvwap1sd = False ;
if (with2sd)
showvwap2sd = True;
else
showvwap2sd = False ;
showvwap3sd = False ;
showvwapband = False ;
showvwapswband = False ;
// showprevdayvals = False ;
// showprev2dayvals = False ;
showprevdayband = False ;
showvwapband = False ;

// showtradearr = False ;
showcomm = False ;
showtext = withsd ;
}

stylelabel = 0 ;
if (showtext)
stylelabel = styleNoLabel ;

styletitle = 0 ;
if (NOT showintitle)
styletitle = styleNoTitle ;

//SetBarsRequired(int(farback*1.1)) ;

if (NOT turnvwapoff)
{
P = (H + L + C) / 3;
nd = Day() != Ref(Day(),-1) ;
Bars_so_far_today = 1 + BarsSince( nd);

bi = BarIndex() ;
bivwap = ValueWhen(nd, bi, ndays) ;
nbar = (bi - bivwap) ;

Bars_so_far_today = ValueWhen(nd, nbar, 1) *ndays ;

TodayVolume = Sum(V,Bars_so_far_today);
//IIf (BarIndex() >= StartBar, VWAP = Sum (C * V, Bars_so_far_today ) / TodayVolume,0);
//Plot (VWAP,"VWAP",colorBlack, styleThick);

CumV = Sum(V,Bars_so_far_today);
CumVWP = Sum (P * V, Bars_so_far_today );
VWAP = CumVWP / CumV;
// S = Sum(Ref(CumV, 0) * V * (P - Ref(VWAP, 0))^2,Bars_so_far_today) / CumV;
VWAPsd = IIf(Ref(nd, 1), 0, VWAP);
CumVsd = IIf(Ref(nd, 1), 0, CumV);

S = Sum(Ref(CumVsd, -1) * V * (P - Ref(VWAPsd, -1))^2 / CumV,Bars_so_far_today);
Variance = S / CumV;
SD = sqrt(Variance);
// VWAP = IIf(InRange, VWAP, Null);
Vwapm1 = VWAP - SD ;
Vwapp1 = VWAP + SD ;
Vwapm2 = VWAP -2*SD ;
Vwapp2 = VWAP +2*SD ;
Vwapm3 = VWAP -3*SD ;
Vwapp3 = VWAP +3*SD ;

dt = DateTime() ;
dtnum = DateTimeConvert(0, dt) ;
newdt = dtnum != Ref(dtnum, -1) ;

Lastbar = H-H ;
if (Filterdaych)
Lastbar = dtnum != Ref(dtnum, 1) ;

RefVWAP = VWAP;
RefVwapm1 = Vwapm1;
RefVwapp1 = Vwapp1 ;
RefVwapm2 = Vwapm2;
RefVwapp2 = Vwapp2;
RefVwapm3 = Vwapm3;
RefVwapp3 = Vwapp3;

Clrvwap = ParamColor("Color VWAP",colorBlue) ;
Clrvwapm1 = ParamColor("Color VWAP -1SD", colorViolet) ;
Clrvwapp1 = ParamColor("Color VWAP +1SD", colorViolet) ;

if (showvwap)
{
// Vwapstyle = 0 ;
strnday = NumToStr(ndays, 1.0)+"day";
// if (ndays > 1)
Vwapstyle = styleNoRescale ;
Plot(IIf(Lastbar, Null, RefVWAP), "VWAP"+strnday, Clrvwap , styleThick|stylelabel|Vwapstyle, Null, Null, 0, 1);
if (MAwidth > 0)
PlotOHLC(IIf(Lastbar, Null, RefVWAP+MAwidth), IIf(Lastbar, Null, RefVWAP+MAwidth), IIf(Lastbar, Null, RefVWAP-MAwidth), IIf(Lastbar, Null, RefVWAP-MAwidth), "",Clrvwap, styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, 1 ) ;
}

Plot(SD, "SD", colorBlack, styleNoDraw|styleNoLabel|styleNoRescale) ;
if (showvwap1sd)
{
Plot(IIf(Lastbar, Null, RefVwapm1), "-1SD"+strnday, Clrvwapm1, styleThick + styleTitle + stylelabel+styleNoRescale, Null, Null, 0, 1);
Plot(IIf(Lastbar, Null, RefVwapp1), "+1SD"+strnday, Clrvwapp1, styleThick + styleTitle + stylelabel+styleNoRescale, Null, Null, 0, 1);
if (SDwidth > 0)
PlotOHLC(IIf(Lastbar, Null, RefVWAPm1+SDwidth), IIf(Lastbar, Null, RefVWAPm1+SDwidth), IIf(Lastbar, Null, RefVWAPm1-SDwidth), IIf(Lastbar, Null, RefVWAPm1-SDwidth), "",Clrvwapm1, styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, 0 ) ;

if (SDwidth > 0)
PlotOHLC(IIf(Lastbar, Null, RefVWAPp1+SDwidth), IIf(Lastbar, Null, RefVWAPp1+SDwidth), IIf(Lastbar, Null, RefVWAPp1-SDwidth), IIf(Lastbar, Null, RefVWAPp1-SDwidth), "",Clrvwapp1, styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, 0 ) ;

}

if (showvwap2sd)
{
Plot(IIf(Lastbar, Null, RefVwapm2), "-2SD"+strnday, ParamColor("Color VWAP -2SD", colorViolet), styleThick + styleTitle + stylelabel+styleNoRescale, Null, Null, 0, 1);
Plot(IIf(Lastbar, Null, RefVwapp2), "+2SD"+strnday, ParamColor("Color VWAP +2SD", colorViolet), styleThick + styleTitle + stylelabel+styleNoRescale, Null, Null, 0, 1);
if (SDwidth > 0)
PlotOHLC(IIf(Lastbar, Null, RefVWAPm2+SDwidth), IIf(Lastbar, Null, RefVWAPm2+SDwidth), IIf(Lastbar, Null, RefVWAPm2-SDwidth), IIf(Lastbar, Null, RefVWAPm2-SDwidth), "",ParamColor("Color VWAP -2SD", colorViolet), styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, 0 ) ;

if (SDwidth > 0)
PlotOHLC(IIf(Lastbar, Null, RefVWAPp2+SDwidth), IIf(Lastbar, Null, RefVWAPp2+SDwidth), IIf(Lastbar, Null, RefVWAPp2-SDwidth), IIf(Lastbar, Null, RefVWAPp2-SDwidth), "",ParamColor("Color VWAP +2SD", colorViolet), styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, 0 ) ;
}

if (showvwap3sd)
{
Plot(IIf(Lastbar, Null, RefVwapm3), "-3SD"+strnday, ParamColor("Color VWAP -3SD", colorViolet), styleThick + styleNoTitle + stylelabel+styleNoRescale, Null, Null, 0, 1);
Plot(IIf(Lastbar, Null, RefVwapp3), "+3SD"+strnday, ParamColor("Color VWAP +3SD", colorViolet), styleThick + styleNoTitle + stylelabel+styleNoRescale, Null, Null, 0, 1);
}

if (showvwapband)
{
PlotOHLC(IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm2), IIf(Lastbar, Null, RefVwapm2), "",ParamColor("Down Trend", colorPink), styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;
PlotOHLC(IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp2), IIf(Lastbar, Null, RefVwapp2), "",ParamColor("Up Trend", colorPaleTurquoise), styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;
}

// if (showvwapswband)
// {
// PlotOHLC(RefVwapm1, RefVwapm1, RefVwapp1, RefVwapp1, "",ParamColor("Sideways Color", colorLavender), styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;
// }


Ht = H ;
Lt = L ;
Ct = C ;


Avgp = (Ht+Lt+Ct)/3 ;

if (showtradearr)
{

Buy = Avgp >= Refvwapp1 ;
Short = Avgp <= Refvwapm1 ;

Sell = Avgp <= Refvwapp1 ;
Cover = Avgp >= Refvwapm1 ;

Buy = ExRem(Buy, Short OR Sell) ;
Short = ExRem(Short, Buy OR Cover) ;

sdp1touch = False ; // Ht >= Refvwapp1 ;
sdm1touch = False ; //Lt >= Refvwapm1 ;

Sell = ExRem(Sell, Buy OR sdp1touch ) ;
Cover = ExRem(Cover, Short OR sdm1touch ) ;

PlotShapes(Cover*shapeUpArrow, colorBlack, 0, Ht, 12) ;
PlotShapes(Sell*shapeDownArrow, colorBlack, 0, Lt, 12) ;

PlotShapes(Buy*shapeUpArrow, colorBlue, 0, Ht, 12) ;
PlotShapes(Short*shapeDownArrow, colorRed, 0, Lt, 12) ;

}

shift = Param("Shift", 0, -1, 0, 1) ;

prevdayvalue = prevdayvwap = ValueWhen(Ref(newdt,1), RefVWAP, 1) ;
prevdayvaluelow = prevdayvwapm1 = ValueWhen(Ref(newdt,1), RefVwapm1, 1) ;
prevdayvaluehigh = prevdayvwapp1 = ValueWhen(Ref(newdt,1), RefVwapp1, 1) ;
prevdayvwapm2 = ValueWhen(Ref(newdt,1), RefVwapm2, 1) ;

if (showvwapswband)
{

swclr = ParamColor("Sideways Color", colorLavender) ;
upclr = ParamColor("Bull Bias Color", colorPaleTurquoise) ;
dnclr = ParamColor("Bear Bias Color", colorPink) ;

if (ndays >= 1)
{

bandclr = IIf(Refvwap < prevdayvaluelow, dnclr, IIf(Refvwap > prevdayvaluehigh, upclr, swclr)) ;


// top = Min(prevdayvaluehigh, Refvwapp1) ;
// bot = Max(prevdayvaluelow, Refvwapm1) ;

// PlotOHLC(top, top, bot, bot, "",ParamColor("Sideways Color", colorLavender), styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;
PlotOHLC(IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwap), "",bandclr, styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;
PlotOHLC(IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), "",bandclr, styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;

}
else
PlotOHLC(IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), "",swclr, styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;

}

if (showprevdayvals OR showextprevday)
{
if (shift == -1)
{
prevdayvaluehigh = prevdayvwap;
prevdayvalue = prevdayvwapm1 ;
prevdayvaluelow = prevdayvwapm2 ;
}

if (showprevdayvals) //(NOT showextprevday)
{
Plot(IIf(Lastbar, Null, prevdayvalue), "Prev VWAP", Clrvwap, styleDots|styleNoRescale+stylelabel|styleNoTitle) ;
Plot(IIf(Lastbar, Null, prevdayvaluelow), "VAL"+strnday, Clrvwapm1, styleDots|styleNoRescale+stylelabel+styleNoTitle) ;
Plot(IIf(Lastbar, Null, prevdayvaluehigh), "VAH"+strnday, Clrvwapp1, styleDots|styleNoRescale+stylelabel+styleNoTitle) ;
}

Clrprevdayband = ParamColor("Prev Day Band Color", colorRose);
if (showprevdayband)
{
// if (NOT showextprevday)
PlotOHLC(IIf(Lastbar, Null, prevdayvaluelow), IIf(Lastbar, Null, prevdayvaluelow), IIf(Lastbar, Null, prevdayvaluehigh), IIf(Lastbar, Null, prevdayvaluehigh), "",Clrprevdayband, styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;
}

if (showprev2dayvals)
{
prev2dayvalue = prev2dayvwap = ValueWhen(Ref(newdt,1), RefVWAP, 2) ;
prev2dayvaluelow = prev2dayvwapm1 = ValueWhen(Ref(newdt,1), RefVwapm1, 2) ;
prev2dayvaluehigh = prev2dayvwapp1 = ValueWhen(Ref(newdt,1), RefVwapp1, 2) ;
prev2dayvwapm2 = ValueWhen(Ref(newdt,1), RefVwapm2, 2) ;

// if (NOT showextprevday)
{
Plot(IIf(Lastbar, Null, prev2dayvalue), "2day prev VWAP"+strnday, Clrvwap, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle) ;
Plot(IIf(Lastbar, Null, prev2dayvaluelow), "2day VAL"+strnday, Clrvwapm1, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle) ;
Plot(IIf(Lastbar, Null, prev2dayvaluehigh), "2day VAH"+strnday, Clrvwapp1, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle) ;
}
}

if (showextprevday)
{
x0 = BarCount - (extend+1) ;
x1 = BarCount -1 ;

Hdlast = SelectedValue(prevdayvaluehigh ) ;
Ldlast = SelectedValue(prevdayvaluelow ) ;

Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
Plot(Hplot, "VAHext"+strnday, colorOrange, styleLine|styleNoLabel|styleNoRescale, 0,0,extend, extlayer) ;
LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
Plot(LPlot, "VALext"+strnday, colorGreen, styleLine|styleNoLabel|styleNoRescale, 0,0,extend, extlayer) ;

if (showextbandprevday)
PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", Clrprevdayband, styleCloud|styleNoLabel|styleNoRescale, 0,0,extend,extlayer ) ;

}

}


if (showtext)
{
PlotText(NumToStr(RefVwapp1[BarCount-1], 1.1), BarCount+1, RefVwapp1[BarCount-1],Clrtext) ;
PlotText(NumToStr(RefVwapm1[BarCount-1], 1.1), BarCount+1, RefVwapm1[BarCount-1],Clrtext) ;
PlotText(NumToStr(RefVwap[BarCount-1], 1.1), BarCount+1, RefVwap[BarCount-1],Clrtext) ;
PlotText(NumToStr(RefVwapp2[BarCount-1], 1.1), BarCount+1, RefVwapp2[BarCount-1],Clrtext) ;
PlotText(NumToStr(RefVwapm2[BarCount-1], 1.1), BarCount+1, RefVwapm2[BarCount-1],Clrtext) ;
}

if (showvahvaltext)
{
PlotText(NumToStr(prevdayvalue[BarCount-1], 1.1), BarCount+1, prevdayvalue[BarCount-1],Clrtext) ;
PlotText(NumToStr(prevdayvaluelow[BarCount-1], 1.1), BarCount+1, prevdayvaluelow[BarCount-1],Clrtext) ;
PlotText(NumToStr(prevdayvaluehigh[BarCount-1], 1.1), BarCount+1, prevdayvaluehigh[BarCount-1],Clrtext) ;
}

}

_SECTION_END();

_SECTION_BEGIN("SRSARTFtj3min");
usetf = ParamToggle("Use TF", "No|Yes", 1) ;

// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
/*
This creates a band of period-moving average for the given TF
(TF should be equal to or higher than current chart TF).

*/
alloff = ParamToggle("All off", "No|Yes", 0) ;

// Rh = ParamField("High", 1) ;
// Rl = ParamField("Low", 2) ;


tf = Param("TF", 3, 1, 100000, 1);
Periods = Param("Periods", 13, 2, 1000, 1 );
showzone = ParamToggle("Show Zone", "No|Yes", 1) ;
Layer = Param("Layer", -2, -5, 5, 1) ;
shift = Param("Shift", 0, -100, 100, 1) ;
showtitle = ParamToggle("Show Title", "No|Yes", 0) ;
showlabel = ParamToggle("Show Label", "No|Yes", 1) ;
isema = ParamToggle("MA Type", "MA|EMA", 1) ;
MAstyle = ParamStyle("MA Style", styleThick|styleDashed) ;
MAwidthper = Param("MA Width %", 0, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
Clrup = ParamColor( "Color Up", colorPaleGreen);
Clrdown = ParamColor( "Color Down", colorPaleGreen);
Clrsw = ParamColor( "Color SW", colorPaleGreen);
isexpandLast = ParamToggle("Expand Mode", "First|Last", 0);

styledisp = 0 ;
if (NOT showtitle)
styledisp |= styleNoTitle ;

if (NOT showlabel)
styledisp |= styleNoLabel ;

expandmode = expandFirst ;
if (isexpandLast)
expandmode = expandLast ;

if (NOT alloff)
{
Oldintrvl = Interval() ;

if (usetf)
{
tfs = tf *in1Minute ;
TimeFrameSet(tfs) ;
}
else
tfs = Interval() ;

if (isema)
MAhtf = EMA(H, Periods) ;
else
MAhtf = MA(H, Periods) ;

if (isema)
MAltf = EMA(L, Periods) ;
else
MAltf = MA(L, Periods) ;

str = NumToStr(tf, 1.0)+"Min"+"-P"+NumToStr(Periods, 1.0) ;
Clr = IIf(MAltf > Ref(MAltf, -1 ), ClrUp,
IIf(MAhtf < Ref(MAhtf, -1 ), ClrDown,
Clrsw)) ;

if (usetf)
TimeFrameRestore() ; //TimeFrameSet(Oldintrvl) ;

if (usetf)
MAhtfe = TimeFrameExpand(MAhtf, tfs, expandmode ) ;
else
MAhtfe = MAhtf ;

if (usetf)
MAltfe = TimeFrameExpand(MAltf, tfs, expandmode ) ;
else
MAltfe = MAltf ;

if (usetf)
Clre = TimeFrameExpand(Clr, tfs, expandmode ) ;
else
Clre = Clr ;

RefMAhtfe = MAhtfe ;
RefMAltfe = MAltfe ;
RefClre = Clre ;

Plot( RefMAhtfe, str+" High", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
Plot( RefMAltfe, str+" Low", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
if (showzone)
PlotOHLC(RefMAhtfe, RefMAhtfe, RefMAltfe, RefMAltfe, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift, Layer) ;
if (MAwidth > 0)
{
PlotOHLC(RefMAhtfe+MAwidth, RefMAhtfe+MAwidth, RefMAhtfe-MAwidth, RefMAhtfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
PlotOHLC(RefMAltfe+MAwidth, RefMAltfe+MAwidth, RefMAltfe-MAwidth, RefMAltfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
}
showext = ParamToggle("Show Extension", "No|Yes", 1) ;
showextband = ParamToggle("Show Extension Band", "No|Yes", 1) ;
extend = Param("Extend", 20, 0, 100, 1) ;
showparam = ParamToggle("Show Key Param", "No|Yes", 1) ;

if (showext)
{
x0 = BarCount - (extend+1) ;
x1 = BarCount -1 ;

Hdlast = SelectedValue(RefMAhtfe) ;
Ldlast = SelectedValue(RefMAltfe) ;

Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
Plot(Hplot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;
LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
Plot(LPlot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;

if (showextband)
PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale, 0,0,extend,Layer ) ;

}

showparam = ParamToggle("Show Key Param", "No|Yes", 0) ;

if (showparam)
{
y = (SelectedValue(RefMAhtfe)+ SelectedValue(RefMAltfe)) /2 ;
tfsd = tfs ;
if (tfsd < Interval())
tfsd = Interval() ;

str = "TF = " + NumToStr(tfsd/in1Minute, 1.0) + " P = " + NumToStr(Periods, 1.0) ;
PlotText(str, BarCount+2, y, colorBlack) ;
}


}
_SECTION_END();

_SECTION_BEGIN("SRSARTFtj15min");
usetf = ParamToggle("Use TF", "No|Yes", 1) ;

// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
/*
This creates a band of period-moving average for the given TF
(TF should be equal to or higher than current chart TF).

*/
alloff = ParamToggle("All off", "No|Yes", 0) ;

// Rh = ParamField("High", 1) ;
// Rl = ParamField("Low", 2) ;


tf = Param("TF", 15, 1, 100000, 1);
Periods = Param("Periods", 13, 2, 1000, 1 );
showzone = ParamToggle("Show Zone", "No|Yes", 1) ;
Layer = Param("Layer", -2, -5, 5, 1) ;
shift = Param("Shift", 0, -100, 100, 1) ;
showtitle = ParamToggle("Show Title", "No|Yes", 0) ;
showlabel = ParamToggle("Show Label", "No|Yes", 1) ;
isema = ParamToggle("MA Type", "MA|EMA", 1) ;
MAstyle = ParamStyle("MA Style", styleThick|styleDashed) ;
MAwidthper = Param("MA Width %", 0, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
Clrup = ParamColor( "Color Up", colorPaleGreen);
Clrdown = ParamColor( "Color Down", colorPaleGreen);
Clrsw = ParamColor( "Color SW", colorPaleGreen);
isexpandLast = ParamToggle("Expand Mode", "First|Last", 0);

styledisp = 0 ;
if (NOT showtitle)
styledisp |= styleNoTitle ;

if (NOT showlabel)
styledisp |= styleNoLabel ;

expandmode = expandFirst ;
if (isexpandLast)
expandmode = expandLast ;

if (NOT alloff)
{
Oldintrvl = Interval() ;

if (usetf)
{
tfs = tf *in1Minute ;
TimeFrameSet(tfs) ;
}
else
tfs = Interval() ;

if (isema)
MAhtf = EMA(H, Periods) ;
else
MAhtf = MA(H, Periods) ;

if (isema)
MAltf = EMA(L, Periods) ;
else
MAltf = MA(L, Periods) ;

str = NumToStr(tf, 1.0)+"Min"+"-P"+NumToStr(Periods, 1.0) ;
Clr = IIf(MAltf > Ref(MAltf, -1 ), ClrUp,
IIf(MAhtf < Ref(MAhtf, -1 ), ClrDown,
Clrsw)) ;

if (usetf)
TimeFrameRestore() ; //TimeFrameSet(Oldintrvl) ;

if (usetf)
MAhtfe = TimeFrameExpand(MAhtf, tfs, expandmode ) ;
else
MAhtfe = MAhtf ;

if (usetf)
MAltfe = TimeFrameExpand(MAltf, tfs, expandmode ) ;
else
MAltfe = MAltf ;

if (usetf)
Clre = TimeFrameExpand(Clr, tfs, expandmode ) ;
else
Clre = Clr ;

RefMAhtfe = MAhtfe ;
RefMAltfe = MAltfe ;
RefClre = Clre ;

Plot( RefMAhtfe, str+" High", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
Plot( RefMAltfe, str+" Low", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
if (showzone)
PlotOHLC(RefMAhtfe, RefMAhtfe, RefMAltfe, RefMAltfe, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift, Layer) ;
if (MAwidth > 0)
{
PlotOHLC(RefMAhtfe+MAwidth, RefMAhtfe+MAwidth, RefMAhtfe-MAwidth, RefMAhtfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
PlotOHLC(RefMAltfe+MAwidth, RefMAltfe+MAwidth, RefMAltfe-MAwidth, RefMAltfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
}
showext = ParamToggle("Show Extension", "No|Yes", 1) ;
showextband = ParamToggle("Show Extension Band", "No|Yes", 1) ;
extend = Param("Extend", 20, 0, 100, 1) ;
showparam = ParamToggle("Show Key Param", "No|Yes", 1) ;

if (showext)
{
x0 = BarCount - (extend+1) ;
x1 = BarCount -1 ;

Hdlast = SelectedValue(RefMAhtfe) ;
Ldlast = SelectedValue(RefMAltfe) ;

Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
Plot(Hplot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;
LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
Plot(LPlot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;

if (showextband)
PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale, 0,0,extend,Layer ) ;

}

showparam = ParamToggle("Show Key Param", "No|Yes", 0) ;

if (showparam)
{
y = (SelectedValue(RefMAhtfe)+ SelectedValue(RefMAltfe)) /2 ;
tfsd = tfs ;
if (tfsd < Interval())
tfsd = Interval() ;

str = "TF = " + NumToStr(tfsd/in1Minute, 1.0) + " P = " + NumToStr(Periods, 1.0) ;
PlotText(str, BarCount+2, y, colorBlack) ;
}


}
_SECTION_END();

_SECTION_BEGIN("SRSARTFtj60min");
usetf = ParamToggle("Use TF", "No|Yes", 1) ;

// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
/*
This creates a band of period-moving average for the given TF
(TF should be equal to or higher than current chart TF).

*/
alloff = ParamToggle("All off", "No|Yes", 0) ;

// Rh = ParamField("High", 1) ;
// Rl = ParamField("Low", 2) ;


tf = Param("TF", 60, 1, 100000, 1);
Periods = Param("Periods", 13, 2, 1000, 1 );
showzone = ParamToggle("Show Zone", "No|Yes", 1) ;
Layer = Param("Layer", -2, -5, 5, 1) ;
shift = Param("Shift", 0, -100, 100, 1) ;
showtitle = ParamToggle("Show Title", "No|Yes", 0) ;
showlabel = ParamToggle("Show Label", "No|Yes", 1) ;
isema = ParamToggle("MA Type", "MA|EMA", 1) ;
MAstyle = ParamStyle("MA Style", styleThick|styleDashed) ;
MAwidthper = Param("MA Width %", 0, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
Clrup = ParamColor( "Color Up", colorPaleGreen);
Clrdown = ParamColor( "Color Down", colorPaleGreen);
Clrsw = ParamColor( "Color SW", colorPaleGreen);
isexpandLast = ParamToggle("Expand Mode", "First|Last", 0);

styledisp = 0 ;
if (NOT showtitle)
styledisp |= styleNoTitle ;

if (NOT showlabel)
styledisp |= styleNoLabel ;

expandmode = expandFirst ;
if (isexpandLast)
expandmode = expandLast ;

if (NOT alloff)
{
Oldintrvl = Interval() ;

if (usetf)
{
tfs = tf *in1Minute ;
TimeFrameSet(tfs) ;
}
else
tfs = Interval() ;

if (isema)
MAhtf = EMA(H, Periods) ;
else
MAhtf = MA(H, Periods) ;

if (isema)
MAltf = EMA(L, Periods) ;
else
MAltf = MA(L, Periods) ;

str = NumToStr(tf, 1.0)+"Min"+"-P"+NumToStr(Periods, 1.0) ;
Clr = IIf(MAltf > Ref(MAltf, -1 ), ClrUp,
IIf(MAhtf < Ref(MAhtf, -1 ), ClrDown,
Clrsw)) ;

if (usetf)
TimeFrameRestore() ; //TimeFrameSet(Oldintrvl) ;

if (usetf)
MAhtfe = TimeFrameExpand(MAhtf, tfs, expandmode ) ;
else
MAhtfe = MAhtf ;

if (usetf)
MAltfe = TimeFrameExpand(MAltf, tfs, expandmode ) ;
else
MAltfe = MAltf ;

if (usetf)
Clre = TimeFrameExpand(Clr, tfs, expandmode ) ;
else
Clre = Clr ;

RefMAhtfe = MAhtfe ;
RefMAltfe = MAltfe ;
RefClre = Clre ;

Plot( RefMAhtfe, str+" High", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
Plot( RefMAltfe, str+" Low", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
if (showzone)
PlotOHLC(RefMAhtfe, RefMAhtfe, RefMAltfe, RefMAltfe, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift, Layer) ;
if (MAwidth > 0)
{
PlotOHLC(RefMAhtfe+MAwidth, RefMAhtfe+MAwidth, RefMAhtfe-MAwidth, RefMAhtfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
PlotOHLC(RefMAltfe+MAwidth, RefMAltfe+MAwidth, RefMAltfe-MAwidth, RefMAltfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
}
showext = ParamToggle("Show Extension", "No|Yes", 1) ;
showextband = ParamToggle("Show Extension Band", "No|Yes", 1) ;
extend = Param("Extend", 20, 0, 100, 1) ;
showparam = ParamToggle("Show Key Param", "No|Yes", 1) ;

if (showext)
{
x0 = BarCount - (extend+1) ;
x1 = BarCount -1 ;

Hdlast = SelectedValue(RefMAhtfe) ;
Ldlast = SelectedValue(RefMAltfe) ;

Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
Plot(Hplot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;
LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
Plot(LPlot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;

if (showextband)
PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale, 0,0,extend,Layer ) ;

}

showparam = ParamToggle("Show Key Param", "No|Yes", 0) ;

if (showparam)
{
y = (SelectedValue(RefMAhtfe)+ SelectedValue(RefMAltfe)) /2 ;
tfsd = tfs ;
if (tfsd < Interval())
tfsd = Interval() ;

str = "TF = " + NumToStr(tfsd/in1Minute, 1.0) + " P = " + NumToStr(Periods, 1.0) ;
PlotText(str, BarCount+2, y, colorBlack) ;
}


}
_SECTION_END();

_SECTION_BEGIN("SRSARTFtj60*24min");
usetf = ParamToggle("Use TF", "No|Yes", 1) ;

// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
/*
This creates a band of period-moving average for the given TF
(TF should be equal to or higher than current chart TF).

*/
alloff = ParamToggle("All off", "No|Yes", 0) ;

// Rh = ParamField("High", 1) ;
// Rl = ParamField("Low", 2) ;

tf = Param("TF", 60*24, 1, 100000, 1);
Periods = Param("Periods", 13, 2, 1000, 1 );
showzone = ParamToggle("Show Zone", "No|Yes", 1) ;
Layer = Param("Layer", -2, -5, 5, 1) ;
shift = Param("Shift", 0, -100, 100, 1) ;
showtitle = ParamToggle("Show Title", "No|Yes", 0) ;
showlabel = ParamToggle("Show Label", "No|Yes", 1) ;
isema = ParamToggle("MA Type", "MA|EMA", 1) ;
MAstyle = ParamStyle("MA Style", styleThick|styleDashed) ;
MAwidthper = Param("MA Width %", 0, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
Clrup = ParamColor( "Color Up", colorPaleGreen);
Clrdown = ParamColor( "Color Down", colorPaleGreen);
Clrsw = ParamColor( "Color SW", colorPaleGreen);
isexpandLast = ParamToggle("Expand Mode", "First|Last", 0);

styledisp = 0 ;
if (NOT showtitle)
styledisp |= styleNoTitle ;

if (NOT showlabel)
styledisp |= styleNoLabel ;

expandmode = expandFirst ;
if (isexpandLast)
expandmode = expandLast ;

if (NOT alloff)
{
Oldintrvl = Interval() ;

if (usetf)
{
tfs = tf *in1Minute ;
TimeFrameSet(tfs) ;
}
else
tfs = Interval() ;

if (isema)
MAhtf = EMA(H, Periods) ;
else
MAhtf = MA(H, Periods) ;

if (isema)
MAltf = EMA(L, Periods) ;
else
MAltf = MA(L, Periods) ;

str = NumToStr(tf, 1.0)+"Min"+"-P"+NumToStr(Periods, 1.0) ;
Clr = IIf(MAltf > Ref(MAltf, -1 ), ClrUp,
IIf(MAhtf < Ref(MAhtf, -1 ), ClrDown,
Clrsw)) ;

if (usetf)
TimeFrameRestore() ; //TimeFrameSet(Oldintrvl) ;

if (usetf)
MAhtfe = TimeFrameExpand(MAhtf, tfs, expandmode ) ;
else
MAhtfe = MAhtf ;

if (usetf)
MAltfe = TimeFrameExpand(MAltf, tfs, expandmode ) ;
else
MAltfe = MAltf ;

if (usetf)
Clre = TimeFrameExpand(Clr, tfs, expandmode ) ;
else
Clre = Clr ;

RefMAhtfe = MAhtfe ;
RefMAltfe = MAltfe ;
RefClre = Clre ;

Plot( RefMAhtfe, str+" High", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
Plot( RefMAltfe, str+" Low", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
if (showzone)
PlotOHLC(RefMAhtfe, RefMAhtfe, RefMAltfe, RefMAltfe, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift, Layer) ;
if (MAwidth > 0)
{
PlotOHLC(RefMAhtfe+MAwidth, RefMAhtfe+MAwidth, RefMAhtfe-MAwidth, RefMAhtfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
PlotOHLC(RefMAltfe+MAwidth, RefMAltfe+MAwidth, RefMAltfe-MAwidth, RefMAltfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
}
showext = ParamToggle("Show Extension", "No|Yes", 1) ;
showextband = ParamToggle("Show Extension Band", "No|Yes", 1) ;
extend = Param("Extend", 20, 0, 100, 1) ;
showparam = ParamToggle("Show Key Param", "No|Yes", 1) ;

if (showext)
{
x0 = BarCount - (extend+1) ;
x1 = BarCount -1 ;

Hdlast = SelectedValue(RefMAhtfe) ;
Ldlast = SelectedValue(RefMAltfe) ;

Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
Plot(Hplot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;
LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
Plot(LPlot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;

if (showextband)
PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale, 0,0,extend,Layer ) ;

}

showparam = ParamToggle("Show Key Param", "No|Yes", 0) ;

if (showparam)
{
y = (SelectedValue(RefMAhtfe)+ SelectedValue(RefMAltfe)) /2 ;
tfsd = tfs ;
if (tfsd < Interval())
tfsd = Interval() ;

str = "TF = " + NumToStr(tfsd/in1Minute, 1.0) + " P = " + NumToStr(Periods, 1.0) ;
PlotText(str, BarCount+2, y, colorBlack) ;
}


}
_SECTION_END();

_SECTION_BEGIN("SRSARTFtj60*24*5min");
usetf = ParamToggle("Use TF", "No|Yes", 1) ;

// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
/*
This creates a band of period-moving average for the given TF
(TF should be equal to or higher than current chart TF).

*/
alloff = ParamToggle("All off", "No|Yes", 0) ;

// Rh = ParamField("High", 1) ;
// Rl = ParamField("Low", 2) ;

tf = Param("TF", 60*24*5, 1, 100000, 1);
Periods = Param("Periods", 13, 2, 1000, 1 );
showzone = ParamToggle("Show Zone", "No|Yes", 1) ;
Layer = Param("Layer", -2, -5, 5, 1) ;
shift = Param("Shift", 0, -100, 100, 1) ;
showtitle = ParamToggle("Show Title", "No|Yes", 0) ;
showlabel = ParamToggle("Show Label", "No|Yes", 1) ;
isema = ParamToggle("MA Type", "MA|EMA", 1) ;
MAstyle = ParamStyle("MA Style", styleThick|styleDashed) ;
MAwidthper = Param("MA Width %", 0, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
Clrup = ParamColor( "Color Up", colorPaleGreen);
Clrdown = ParamColor( "Color Down", colorPaleGreen);
Clrsw = ParamColor( "Color SW", colorPaleGreen);
isexpandLast = ParamToggle("Expand Mode", "First|Last", 0);

styledisp = 0 ;
if (NOT showtitle)
styledisp |= styleNoTitle ;

if (NOT showlabel)
styledisp |= styleNoLabel ;

expandmode = expandFirst ;
if (isexpandLast)
expandmode = expandLast ;

if (NOT alloff)
{
Oldintrvl = Interval() ;

if (usetf)
{
tfs = tf *in1Minute ;
TimeFrameSet(tfs) ;
}
else
tfs = Interval() ;

if (isema)
MAhtf = EMA(H, Periods) ;
else
MAhtf = MA(H, Periods) ;

if (isema)
MAltf = EMA(L, Periods) ;
else
MAltf = MA(L, Periods) ;

str = NumToStr(tf, 1.0)+"Min"+"-P"+NumToStr(Periods, 1.0) ;
Clr = IIf(MAltf > Ref(MAltf, -1 ), ClrUp,
IIf(MAhtf < Ref(MAhtf, -1 ), ClrDown,
Clrsw)) ;

if (usetf)
TimeFrameRestore() ; //TimeFrameSet(Oldintrvl) ;

if (usetf)
MAhtfe = TimeFrameExpand(MAhtf, tfs, expandmode ) ;
else
MAhtfe = MAhtf ;

if (usetf)
MAltfe = TimeFrameExpand(MAltf, tfs, expandmode ) ;
else
MAltfe = MAltf ;

if (usetf)
Clre = TimeFrameExpand(Clr, tfs, expandmode ) ;
else
Clre = Clr ;

RefMAhtfe = MAhtfe ;
RefMAltfe = MAltfe ;
RefClre = Clre ;

Plot( RefMAhtfe, str+" High", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
Plot( RefMAltfe, str+" Low", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
if (showzone)
PlotOHLC(RefMAhtfe, RefMAhtfe, RefMAltfe, RefMAltfe, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift, Layer) ;
if (MAwidth > 0)
{
PlotOHLC(RefMAhtfe+MAwidth, RefMAhtfe+MAwidth, RefMAhtfe-MAwidth, RefMAhtfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
PlotOHLC(RefMAltfe+MAwidth, RefMAltfe+MAwidth, RefMAltfe-MAwidth, RefMAltfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
}
showext = ParamToggle("Show Extension", "No|Yes", 1) ;
showextband = ParamToggle("Show Extension Band", "No|Yes", 1) ;
extend = Param("Extend", 20, 0, 100, 1) ;
showparam = ParamToggle("Show Key Param", "No|Yes", 1) ;

if (showext)
{
x0 = BarCount - (extend+1) ;
x1 = BarCount -1 ;

Hdlast = SelectedValue(RefMAhtfe) ;
Ldlast = SelectedValue(RefMAltfe) ;

Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
Plot(Hplot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;
LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
Plot(LPlot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;

if (showextband)
PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale, 0,0,extend,Layer ) ;

}

showparam = ParamToggle("Show Key Param", "No|Yes", 0) ;

if (showparam)
{
y = (SelectedValue(RefMAhtfe)+ SelectedValue(RefMAltfe)) /2 ;
tfsd = tfs ;
if (tfsd < Interval())
tfsd = Interval() ;

str = "TF = " + NumToStr(tfsd/in1Minute, 1.0) + " P = " + NumToStr(Periods, 1.0) ;
PlotText(str, BarCount+2, y, colorBlack) ;
}


}
_SECTION_END();

_SECTION_BEGIN("SRSARTFtj60*24*5*4.2min");
usetf = ParamToggle("Use TF", "No|Yes", 1) ;

// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
/*
This creates a band of period-moving average for the given TF
(TF should be equal to or higher than current chart TF).

*/
alloff = ParamToggle("All off", "No|Yes", 0) ;

// Rh = ParamField("High", 1) ;
// Rl = ParamField("Low", 2) ;

tf = Param("TF", 60*24*5*4.2, 1, 100000, 1);
Periods = Param("Periods", 13, 2, 1000, 1 );
showzone = ParamToggle("Show Zone", "No|Yes", 1) ;
Layer = Param("Layer", -2, -5, 5, 1) ;
shift = Param("Shift", 0, -100, 100, 1) ;
showtitle = ParamToggle("Show Title", "No|Yes", 0) ;
showlabel = ParamToggle("Show Label", "No|Yes", 1) ;
isema = ParamToggle("MA Type", "MA|EMA", 1) ;
MAstyle = ParamStyle("MA Style", styleThick|styleDashed) ;
MAwidthper = Param("MA Width %", 0, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
Clrup = ParamColor( "Color Up", colorPaleGreen);
Clrdown = ParamColor( "Color Down", colorPaleGreen);
Clrsw = ParamColor( "Color SW", colorPaleGreen);
isexpandLast = ParamToggle("Expand Mode", "First|Last", 0);

styledisp = 0 ;
if (NOT showtitle)
styledisp |= styleNoTitle ;

if (NOT showlabel)
styledisp |= styleNoLabel ;

expandmode = expandFirst ;
if (isexpandLast)
expandmode = expandLast ;

if (NOT alloff)
{
Oldintrvl = Interval() ;

if (usetf)
{
tfs = tf *in1Minute ;
TimeFrameSet(tfs) ;
}
else
tfs = Interval() ;

if (isema)
MAhtf = EMA(H, Periods) ;
else
MAhtf = MA(H, Periods) ;

if (isema)
MAltf = EMA(L, Periods) ;
else
MAltf = MA(L, Periods) ;

str = NumToStr(tf, 1.0)+"Min"+"-P"+NumToStr(Periods, 1.0) ;
Clr = IIf(MAltf > Ref(MAltf, -1 ), ClrUp,
IIf(MAhtf < Ref(MAhtf, -1 ), ClrDown,
Clrsw)) ;

if (usetf)
TimeFrameRestore() ; //TimeFrameSet(Oldintrvl) ;

if (usetf)
MAhtfe = TimeFrameExpand(MAhtf, tfs, expandmode ) ;
else
MAhtfe = MAhtf ;

if (usetf)
MAltfe = TimeFrameExpand(MAltf, tfs, expandmode ) ;
else
MAltfe = MAltf ;

if (usetf)
Clre = TimeFrameExpand(Clr, tfs, expandmode ) ;
else
Clre = Clr ;

RefMAhtfe = MAhtfe ;
RefMAltfe = MAltfe ;
RefClre = Clre ;

Plot( RefMAhtfe, str+" High", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
Plot( RefMAltfe, str+" Low", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
if (showzone)
PlotOHLC(RefMAhtfe, RefMAhtfe, RefMAltfe, RefMAltfe, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift, Layer) ;
if (MAwidth > 0)
{
PlotOHLC(RefMAhtfe+MAwidth, RefMAhtfe+MAwidth, RefMAhtfe-MAwidth, RefMAhtfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
PlotOHLC(RefMAltfe+MAwidth, RefMAltfe+MAwidth, RefMAltfe-MAwidth, RefMAltfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
}
showext = ParamToggle("Show Extension", "No|Yes", 1) ;
showextband = ParamToggle("Show Extension Band", "No|Yes", 1) ;
extend = Param("Extend", 20, 0, 100, 1) ;
showparam = ParamToggle("Show Key Param", "No|Yes", 1) ;

if (showext)
{
x0 = BarCount - (extend+1) ;
x1 = BarCount -1 ;

Hdlast = SelectedValue(RefMAhtfe) ;
Ldlast = SelectedValue(RefMAltfe) ;

Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
Plot(Hplot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;
LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
Plot(LPlot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;

if (showextband)
PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale, 0,0,extend,Layer ) ;

}

showparam = ParamToggle("Show Key Param", "No|Yes", 0) ;

if (showparam)
{
y = (SelectedValue(RefMAhtfe)+ SelectedValue(RefMAltfe)) /2 ;
tfsd = tfs ;
if (tfsd < Interval())
tfsd = Interval() ;

str = "TF = " + NumToStr(tfsd/in1Minute, 1.0) + " P = " + NumToStr(Periods, 1.0) ;
PlotText(str, BarCount+2, y, colorBlack) ;
}


}
_SECTION_END();
 
Last edited:

amitrandive

Well-Known Member
#9


BNF DAILY CHART....

Chart shows how at weekly bands & Monthly bands price takes support & resistance..it put an alert on us for profit booking when we are near these bands...
Vikas

Thanks for the AFL :clap::clap::clap:

Can you please guide on the parameters to get a picture similar to the one you have posted?:confused:
 

Similar threads