Price Action perspective using VWAP+SD and TF AMAs

pratapvb

Well-Known Member


why error in certain scrips in ama sir , most scrips showing ok but in certain scrips this problem is showing
it happens when two adjacent bars h l or c is EXACTLY EQUAL to the paisa

I think I had fixed this

fixed generic AMATF

Code:
datamode = ParamToggle("Data Mode", "No|Yes", 0) ;
showintitle = ParamToggle("Show in Title", "No|Yes", 0) ;
showlabel = ParamToggle("Show Label", "No|Yes", 1) ;

usetf = ParamToggle("Use TF", "No|Yes", 0) ;
tf = Param("TF", 6, 1, 100000, 1) ;
isexpandLast = ParamToggle("Expand Mode", "First|Last", 1) ;
expandmode = IIf(isexpandLast, expandLast, expandFirst) ;

period = Param("Period", 30, 1, 100, 1) ;
noiseperiod = Param("Noise Period", 5, 1, 100, 1) ;
Clr = ParamColor("AMA Color", colorLightOrange) ;
ClrClose = ParamColor("AMA Close Color", colorOrange) ;

MAwidthper = Param("MA Width %", 0.005, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
showasband = ParamToggle("Show as band", "No|Yes", 1) ;
Onlyclose = ParamToggle("Show Only Close", "No|Yes", 0) ;
showclosebias = ParamToggle("Show Close Bias", "No|Yes", 0) ;
Closebiasht = Param("Close bias Ht", 4, 0, 100) ;
Clrbiasup = ParamColor("Color Bias Up", colorSkyblue) ;
Clrbiasdn = ParamColor("Color Bias Down", colorRose) ;
Clrbiasnone = ParamColor("Color Bias None", colorLavender) ;

Clrband = ParamColor("Color Band", colorGold) ;
bandlevel = Param("Level Band", -1, -5, 5, 1) ;
tradearr = ParamToggle("Show Trade Arrow", "No|Yes", 0) ;
triggertypepvt = ParamToggle("Trigger Type", "Bar|Pvt", 0) ;
Onbody= ParamToggle("BO style", "H-L|Body", 1) ;

datamodestyle = styleNoRescale ;
if (NOT showintitle)
	datamodestyle |= styleNoTitle ;
if (NOT showlabel)
	datamodestyle |= styleNoLabel ;

if (datamode)
	datamodestyle = styleNoDraw|styleNoTitle|styleNoLabel|styleNoRescale ;

onlyClosestyle = 0 ;
if (Onlyclose)
	OnlyClosestyle = styleNoDraw ;

tfs = tf *in1Minute ;
if (usetf)
	TimeFrameSet(tfs) ;

tfma = int(Interval()/60) ;
if (usetf AND tfs >= Interval())
	tfma = tf ;

strtf = NumToStr(tfma, 8.0)+"min" ;

Refo = ParamField("TF Open", 0) ;
Refh = ParamField("TF High", 1) ;
Refl = ParamField("TF Low", 2) ;
Refc = ParamField("TF Close", 3) ;
//Refbi = ParamField("BI", 4) ;

//Plot(EMA( Close, period ), "", colorRed) ;
fast = 2/(2+1);
slow = 2/(period+1);
dir=abs(Refc -Ref(Refc ,-noiseperiod ));
vol=Sum(abs(Refc -Ref(Refc,-1)),noiseperiod );
//ER=dir/vol;
ER=IIf(vol == 0, Ref(vol, -1), dir/vol);
sc =( ER*(fast-slow)+slow)^2; 
amaplotcx = AMA( Refc, sc ); 

dirh=abs(Refh -Ref(Refh ,-noiseperiod ));
volh=Sum(abs(Refh -Ref(Refh,-1)),noiseperiod );
//ERh=dirh/volh;
ERh=IIf(volh == 0, Ref(volh, -1), dirh/volh);
sch =( ERh*(fast-slow)+slow)^2; 
amaplothx = AMA( Refh, sch ); 

dirl=abs(Refl -Ref(Refl ,-noiseperiod ));
voll=Sum(abs(Refl -Ref(Refl,-1)),noiseperiod );
ERl=IIf(voll == 0, Ref(voll, -1), dirl/voll);
scl =( ERl*(fast-slow)+slow)^2; 
amaplotlx = AMA( Refl, scl ); 

	amaplotc = amaplotcx ;
	amaploth = amaplothx ;
	amaplotl = amaplotlx ;

if (usetf)
{
	amaplotc = TimeFrameExpand(amaplotcx, tfs, expandmode) ;
	amaploth = TimeFrameExpand(amaplothx, tfs, expandmode) ;
	amaplotl = TimeFrameExpand(amaplotlx, tfs, expandmode) ;

	TimeFrameRestore() ;
}

	showoncrb = ParamToggle("Show On CRB", "No|Yes", 0) ;
	Refo = ParamField("CRB Open", 7+0) ;
	Refh = ParamField("CRB High", 7+1) ;
	Refl = ParamField("CRB Low", 7+2) ;
	Refc = ParamField("CRB Close", 7+3) ;
	Refbi = ParamField("CRB BI", 7+4) ;
	Refcrbbars = ParamField("CRB Bars", 7+5) ;
	Refnbars = ParamField("TF Bars", 7+6) ;
	Refdt = ParamField("CRB DT", 7+7) ;


	if (showoncrb)
	{
		diffbars = Refnbars -Refcrbbars -1 ;

		// convert to crb
		Refamaploth = Ref(amaploth, -diffbars) ;
		Refamaplotc = Ref(amaplotc, -diffbars) ;
		Refamaplotl = Ref(amaplotl, -diffbars) ;

//		RefClre = Ref(Clr, -diffbars) ;

		k = 0 ;
		for ( i = Crbst ; i < BarCount ; i++)
		{
			Refbar = Refbi[i];

			Refamaploth[i] = amaploth[Refbar] ;
			Refamaplotc[i] = amaplotc[Refbar] ;
			Refamaplotl[i] = amaplotl[Refbar] ;

//			RefClre[i] = Clr[Refbar];
			k++;
		}
	}
	else
	{
		Refamaploth = amaploth ;
		Refamaplotc = amaplotc ;
		Refamaplotl = amaplotl ;
//		RefClre = Clre ;
	}


Plot(Refamaplotc, strtf+"AMA close"+NumToStr(period, 1.0)+" "+ NumToStr(noiseperiod , 1.0), ClrClose, styleThick|datamodestyle) ;
Plot(Refamaploth, strtf+"AMA high"+NumToStr(period, 1.0)+" "+ NumToStr(noiseperiod , 1.0), Clr, styleThick|datamodestyle|OnlyClosestyle) ;
Plot(Refamaplotl, strtf+"AMA low"+NumToStr(period, 1.0)+" "+ NumToStr(noiseperiod , 1.0), Clr, styleThick|datamodestyle|OnlyClosestyle) ;
if (MAwidth > 0)
	PlotOHLC(Refamaplotc+MAwidth, Refamaplotc+MAwidth, Refamaplotc-MAwidth, Refamaplotc-MAwidth, "", ClrClose , styleCloud|styleNoLabel|datamodestyle) ;
if (showasband)
{
	PlotOHLC(Refamaploth, Refamaploth, Refamaplotl, Refamaplotl, "", Clrband, styleCloud|styleNoLabel|datamodestyle|OnlyClosestyle, 0, 0, 0, bandlevel) ;
}

if (showclosebias)
{
	upside = Refamaploth-(Refamaploth-Refamaplotl)/3 ;
	dnside = Refamaplotl+(Refamaploth-Refamaplotl)/3 ;

	up = Refamaplotc >= upside ;
	dn = Refamaplotc <= dnside ;

	Clr = IIf(up, Clrbiasup, IIf(dn, Clrbiasdn,Clrbiasnone)) ;

	Plot(Closebiasht, "", Clr, styleArea|styleNoLabel|styleOwnScale, 0, 100) ;
}

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

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

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

showrib = ParamToggle("Show Ribbon", "No|Yes", 0) ;
barht = Param("Bar Ht", 4, 1, 100) ;

Refo = ParamField("Open", 0) ;
Refh = ParamField("High", 1) ;
Refl = ParamField("Low", 2) ;
Refc = ParamField("Close", 3) ;

if (showrib)
{
	Buy = Refc > Max(Refamaplotc, Refamaploth) ;
	Short = Refc < Min(Refamaplotc, Refamaplotl) ;

	up = Flip(Buy, Short) ;
	dn = Flip(Short, Buy) ;

	Clr = IIf(up, colorBlue, colorRed) ;

	Plot(barht, "", Clr, styleArea|styleNoLabel|styleOwnScale, 0, 100) ;
}

isemapvts = ParamToggle("Pvt Type", "H-L|EMA", 1) ;

if (tradearr)// AND NOT datamode)
{
avgP = (Refh+refl+Refc)/3 ;
p1 = Param("Fast", 1, 1, 100, 1) ;
p2 = Param("Slow", 3, 1, 100, 1) ;

ismph = H-H ;
ismpl = L-L ;
if (isemapvts)
{
EMA1 = EMA(avgP, p1) ;
EMA2 = EMA(avgP, p2) ;

upcross = Cross(EMA1, EMA2) ;
downcross = Cross(EMA2, EMA1) ;

bi = BarIndex() ; 

mphbar = HighestSinceBars(upcross, Refh) ;
mplbar = LowestSinceBars(downcross, Refl) ;

mphbi = ValueWhen(downcross, bi, 0) - ValueWhen(downcross, mphbar, 0) ;
ismph = mphbi == bi ;

mplbi = ValueWhen(upCross, bi, 0) - ValueWhen(upCross, mplbar, 0) ;
ismpl = mplbi == bi ;

ismph = IIf(downCross AND mphbar == 0, True, ismph) ;
ismpl = IIf(upcross AND mplbar == 0, True, ismpl) ;
}
else
{
	ismph = H >= Ref(H, -1) AND H > Ref(H, 1) ;
	ismpl = L <= Ref(L, -1) AND L < Ref(L, 1) ;
/*
	ismph = ExRem(ismph, ismpl) ;
	ismpl = ExRem(ismpl, ismph) ;
	isbmph = ExRem(isbmph, isbmpl) ;
	isbmpl = ExRem(isbmpl, isbmph) ;
*/

}


showminor = ParamToggle("Show Minor Pvts", "No|Yes", 1) ;
showminorlvls = ParamToggle("Show Minor Levels", "No|Yes", 1) ;

issquare = ParamToggle("Pvt style", "Circle|Square", 0) ;
pvtmarker = IIf(issquare, shapeSmallSquare, shapeSmallCircle) ;

if (showminor)
{
	PlotShapes(ismph*pvtmarker , colorRed, 0, Refh, 12) ;
	PlotShapes(ismpl*pvtmarker , colorGreen, 0, Refl, -12) ;
}

mph = ValueWhen(ismph, Refh) ;
mpl = ValueWhen(ismpl, Refl) ;

if (showminorlvls)
{
	x = LineArray(0, SelectedValue(mph), (BarCount-1), SelectedValue(mph));

	Plot(x, "", colorGold, styleDashed);

	x = LineArray(0, SelectedValue(mpl), (BarCount-1), SelectedValue(mpl));

	Plot(x, "", colorGold, styleDashed);
}


	Reflow = Refl ;
	Refhigh = Refh ;
	if (Onbody)
	{
		Reflow = Min(Refo, Refc) ;
		Refhigh = Max(Refo, Refc) ;
	}
	
	if (triggertypepvt)
	{
		Buy = ismph AND Refhigh > AMAploth ;
		Short = ismpl AND Reflow < AMAplotl ;
	}
	else
	{
		Buy = avgP > AMAploth ;
		Short = avgP < AMAplotl ;
	}

	Buy = ExRem(Buy, Short OR Refc < AMAploth ) ;
	Short = ExRem(Short, Buy OR Refc > AMAplotl ) ;

	Sell = (Refc < AMAploth AND NOT Refc  < AMAplotl AND Refl > AMAplotl) ;
	Cover = (Refc  > AMAplotl AND NOT Refc  > AMAploth AND Refh < AMAploth) ;

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

	PlotShapes(Buy*shapeUpTriangle, colorGreen, 0, Refh, 12) ;
	PlotShapes(Short*shapeDownTriangle, colorBrown, 0, Refl, 12) ;

	showsl = ParamToggle("Show SL", "No|Yes", 0) ;
	if (showsl)
	{
		PlotShapes(Cover*shapeSmallUpTriangle, colorBlack, 0, Refh, 12) ;
		PlotShapes(Sell*shapeSmallDownTriangle, colorBlack, 0, Refl, 12) ;
	}

}
for those interested the fix is to avoid divide by zero like here
ERl=IIf(voll == 0, Ref(voll, -1), dirl/voll);

there are 3 such fixes ...one each for h l and c
 

princy01

Well-Known Member
it happens when two adjacent bars h l or c is EXACTLY EQUAL to the paisa

I think I had fixed this

fixed generic AMATF

Code:
datamode = ParamToggle("Data Mode", "No|Yes", 0) ;
showintitle = ParamToggle("Show in Title", "No|Yes", 0) ;
showlabel = ParamToggle("Show Label", "No|Yes", 1) ;

usetf = ParamToggle("Use TF", "No|Yes", 0) ;
tf = Param("TF", 6, 1, 100000, 1) ;
isexpandLast = ParamToggle("Expand Mode", "First|Last", 1) ;
expandmode = IIf(isexpandLast, expandLast, expandFirst) ;

period = Param("Period", 30, 1, 100, 1) ;
noiseperiod = Param("Noise Period", 5, 1, 100, 1) ;
Clr = ParamColor("AMA Color", colorLightOrange) ;
ClrClose = ParamColor("AMA Close Color", colorOrange) ;

MAwidthper = Param("MA Width %", 0.005, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
showasband = ParamToggle("Show as band", "No|Yes", 1) ;
Onlyclose = ParamToggle("Show Only Close", "No|Yes", 0) ;
showclosebias = ParamToggle("Show Close Bias", "No|Yes", 0) ;
Closebiasht = Param("Close bias Ht", 4, 0, 100) ;
Clrbiasup = ParamColor("Color Bias Up", colorSkyblue) ;
Clrbiasdn = ParamColor("Color Bias Down", colorRose) ;
Clrbiasnone = ParamColor("Color Bias None", colorLavender) ;

Clrband = ParamColor("Color Band", colorGold) ;
bandlevel = Param("Level Band", -1, -5, 5, 1) ;
tradearr = ParamToggle("Show Trade Arrow", "No|Yes", 0) ;
triggertypepvt = ParamToggle("Trigger Type", "Bar|Pvt", 0) ;
Onbody= ParamToggle("BO style", "H-L|Body", 1) ;

datamodestyle = styleNoRescale ;
if (NOT showintitle)
	datamodestyle |= styleNoTitle ;
if (NOT showlabel)
	datamodestyle |= styleNoLabel ;

if (datamode)
	datamodestyle = styleNoDraw|styleNoTitle|styleNoLabel|styleNoRescale ;

onlyClosestyle = 0 ;
if (Onlyclose)
	OnlyClosestyle = styleNoDraw ;

tfs = tf *in1Minute ;
if (usetf)
	TimeFrameSet(tfs) ;

tfma = int(Interval()/60) ;
if (usetf AND tfs >= Interval())
	tfma = tf ;

strtf = NumToStr(tfma, 8.0)+"min" ;

Refo = ParamField("TF Open", 0) ;
Refh = ParamField("TF High", 1) ;
Refl = ParamField("TF Low", 2) ;
Refc = ParamField("TF Close", 3) ;
//Refbi = ParamField("BI", 4) ;

//Plot(EMA( Close, period ), "", colorRed) ;
fast = 2/(2+1);
slow = 2/(period+1);
dir=abs(Refc -Ref(Refc ,-noiseperiod ));
vol=Sum(abs(Refc -Ref(Refc,-1)),noiseperiod );
//ER=dir/vol;
ER=IIf(vol == 0, Ref(vol, -1), dir/vol);
sc =( ER*(fast-slow)+slow)^2; 
amaplotcx = AMA( Refc, sc ); 

dirh=abs(Refh -Ref(Refh ,-noiseperiod ));
volh=Sum(abs(Refh -Ref(Refh,-1)),noiseperiod );
//ERh=dirh/volh;
ERh=IIf(volh == 0, Ref(volh, -1), dirh/volh);
sch =( ERh*(fast-slow)+slow)^2; 
amaplothx = AMA( Refh, sch ); 

dirl=abs(Refl -Ref(Refl ,-noiseperiod ));
voll=Sum(abs(Refl -Ref(Refl,-1)),noiseperiod );
ERl=IIf(voll == 0, Ref(voll, -1), dirl/voll);
scl =( ERl*(fast-slow)+slow)^2; 
amaplotlx = AMA( Refl, scl ); 

	amaplotc = amaplotcx ;
	amaploth = amaplothx ;
	amaplotl = amaplotlx ;

if (usetf)
{
	amaplotc = TimeFrameExpand(amaplotcx, tfs, expandmode) ;
	amaploth = TimeFrameExpand(amaplothx, tfs, expandmode) ;
	amaplotl = TimeFrameExpand(amaplotlx, tfs, expandmode) ;

	TimeFrameRestore() ;
}

	showoncrb = ParamToggle("Show On CRB", "No|Yes", 0) ;
	Refo = ParamField("CRB Open", 7+0) ;
	Refh = ParamField("CRB High", 7+1) ;
	Refl = ParamField("CRB Low", 7+2) ;
	Refc = ParamField("CRB Close", 7+3) ;
	Refbi = ParamField("CRB BI", 7+4) ;
	Refcrbbars = ParamField("CRB Bars", 7+5) ;
	Refnbars = ParamField("TF Bars", 7+6) ;
	Refdt = ParamField("CRB DT", 7+7) ;


	if (showoncrb)
	{
		diffbars = Refnbars -Refcrbbars -1 ;

		// convert to crb
		Refamaploth = Ref(amaploth, -diffbars) ;
		Refamaplotc = Ref(amaplotc, -diffbars) ;
		Refamaplotl = Ref(amaplotl, -diffbars) ;

//		RefClre = Ref(Clr, -diffbars) ;

		k = 0 ;
		for ( i = Crbst ; i < BarCount ; i++)
		{
			Refbar = Refbi[i];

			Refamaploth[i] = amaploth[Refbar] ;
			Refamaplotc[i] = amaplotc[Refbar] ;
			Refamaplotl[i] = amaplotl[Refbar] ;

//			RefClre[i] = Clr[Refbar];
			k++;
		}
	}
	else
	{
		Refamaploth = amaploth ;
		Refamaplotc = amaplotc ;
		Refamaplotl = amaplotl ;
//		RefClre = Clre ;
	}


Plot(Refamaplotc, strtf+"AMA close"+NumToStr(period, 1.0)+" "+ NumToStr(noiseperiod , 1.0), ClrClose, styleThick|datamodestyle) ;
Plot(Refamaploth, strtf+"AMA high"+NumToStr(period, 1.0)+" "+ NumToStr(noiseperiod , 1.0), Clr, styleThick|datamodestyle|OnlyClosestyle) ;
Plot(Refamaplotl, strtf+"AMA low"+NumToStr(period, 1.0)+" "+ NumToStr(noiseperiod , 1.0), Clr, styleThick|datamodestyle|OnlyClosestyle) ;
if (MAwidth > 0)
	PlotOHLC(Refamaplotc+MAwidth, Refamaplotc+MAwidth, Refamaplotc-MAwidth, Refamaplotc-MAwidth, "", ClrClose , styleCloud|styleNoLabel|datamodestyle) ;
if (showasband)
{
	PlotOHLC(Refamaploth, Refamaploth, Refamaplotl, Refamaplotl, "", Clrband, styleCloud|styleNoLabel|datamodestyle|OnlyClosestyle, 0, 0, 0, bandlevel) ;
}

if (showclosebias)
{
	upside = Refamaploth-(Refamaploth-Refamaplotl)/3 ;
	dnside = Refamaplotl+(Refamaploth-Refamaplotl)/3 ;

	up = Refamaplotc >= upside ;
	dn = Refamaplotc <= dnside ;

	Clr = IIf(up, Clrbiasup, IIf(dn, Clrbiasdn,Clrbiasnone)) ;

	Plot(Closebiasht, "", Clr, styleArea|styleNoLabel|styleOwnScale, 0, 100) ;
}

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

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

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

showrib = ParamToggle("Show Ribbon", "No|Yes", 0) ;
barht = Param("Bar Ht", 4, 1, 100) ;

Refo = ParamField("Open", 0) ;
Refh = ParamField("High", 1) ;
Refl = ParamField("Low", 2) ;
Refc = ParamField("Close", 3) ;

if (showrib)
{
	Buy = Refc > Max(Refamaplotc, Refamaploth) ;
	Short = Refc < Min(Refamaplotc, Refamaplotl) ;

	up = Flip(Buy, Short) ;
	dn = Flip(Short, Buy) ;

	Clr = IIf(up, colorBlue, colorRed) ;

	Plot(barht, "", Clr, styleArea|styleNoLabel|styleOwnScale, 0, 100) ;
}

isemapvts = ParamToggle("Pvt Type", "H-L|EMA", 1) ;

if (tradearr)// AND NOT datamode)
{
avgP = (Refh+refl+Refc)/3 ;
p1 = Param("Fast", 1, 1, 100, 1) ;
p2 = Param("Slow", 3, 1, 100, 1) ;

ismph = H-H ;
ismpl = L-L ;
if (isemapvts)
{
EMA1 = EMA(avgP, p1) ;
EMA2 = EMA(avgP, p2) ;

upcross = Cross(EMA1, EMA2) ;
downcross = Cross(EMA2, EMA1) ;

bi = BarIndex() ; 

mphbar = HighestSinceBars(upcross, Refh) ;
mplbar = LowestSinceBars(downcross, Refl) ;

mphbi = ValueWhen(downcross, bi, 0) - ValueWhen(downcross, mphbar, 0) ;
ismph = mphbi == bi ;

mplbi = ValueWhen(upCross, bi, 0) - ValueWhen(upCross, mplbar, 0) ;
ismpl = mplbi == bi ;

ismph = IIf(downCross AND mphbar == 0, True, ismph) ;
ismpl = IIf(upcross AND mplbar == 0, True, ismpl) ;
}
else
{
	ismph = H >= Ref(H, -1) AND H > Ref(H, 1) ;
	ismpl = L <= Ref(L, -1) AND L < Ref(L, 1) ;
/*
	ismph = ExRem(ismph, ismpl) ;
	ismpl = ExRem(ismpl, ismph) ;
	isbmph = ExRem(isbmph, isbmpl) ;
	isbmpl = ExRem(isbmpl, isbmph) ;
*/

}


showminor = ParamToggle("Show Minor Pvts", "No|Yes", 1) ;
showminorlvls = ParamToggle("Show Minor Levels", "No|Yes", 1) ;

issquare = ParamToggle("Pvt style", "Circle|Square", 0) ;
pvtmarker = IIf(issquare, shapeSmallSquare, shapeSmallCircle) ;

if (showminor)
{
	PlotShapes(ismph*pvtmarker , colorRed, 0, Refh, 12) ;
	PlotShapes(ismpl*pvtmarker , colorGreen, 0, Refl, -12) ;
}

mph = ValueWhen(ismph, Refh) ;
mpl = ValueWhen(ismpl, Refl) ;

if (showminorlvls)
{
	x = LineArray(0, SelectedValue(mph), (BarCount-1), SelectedValue(mph));

	Plot(x, "", colorGold, styleDashed);

	x = LineArray(0, SelectedValue(mpl), (BarCount-1), SelectedValue(mpl));

	Plot(x, "", colorGold, styleDashed);
}


	Reflow = Refl ;
	Refhigh = Refh ;
	if (Onbody)
	{
		Reflow = Min(Refo, Refc) ;
		Refhigh = Max(Refo, Refc) ;
	}
	
	if (triggertypepvt)
	{
		Buy = ismph AND Refhigh > AMAploth ;
		Short = ismpl AND Reflow < AMAplotl ;
	}
	else
	{
		Buy = avgP > AMAploth ;
		Short = avgP < AMAplotl ;
	}

	Buy = ExRem(Buy, Short OR Refc < AMAploth ) ;
	Short = ExRem(Short, Buy OR Refc > AMAplotl ) ;

	Sell = (Refc < AMAploth AND NOT Refc  < AMAplotl AND Refl > AMAplotl) ;
	Cover = (Refc  > AMAplotl AND NOT Refc  > AMAploth AND Refh < AMAploth) ;

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

	PlotShapes(Buy*shapeUpTriangle, colorGreen, 0, Refh, 12) ;
	PlotShapes(Short*shapeDownTriangle, colorBrown, 0, Refl, 12) ;

	showsl = ParamToggle("Show SL", "No|Yes", 0) ;
	if (showsl)
	{
		PlotShapes(Cover*shapeSmallUpTriangle, colorBlack, 0, Refh, 12) ;
		PlotShapes(Sell*shapeSmallDownTriangle, colorBlack, 0, Refl, 12) ;
	}

}
for those interested the fix is to avoid divide by zero like here
ERl=IIf(voll == 0, Ref(voll, -1), dirl/voll);

there are 3 such fixes ...one each for h l and c



sir still issues when option price gets below 2-3 rupees , it again shows like this please help and rectify this

regards
 

vivektrader

In persuit of financial independence.
Pratap sir,How can I get +1sd and -1sd for vwap for nifty futures (without amibroker or afl, too geeky for me) on EOD basis?
Thanks
 

pratapvb

Well-Known Member
Pratap sir,How can I get +1sd and -1sd for vwap for nifty futures (without amibroker or afl, too geeky for me) on EOD basis?
Thanks
It has to be calculated bar by bar preferrably in 1min chart or max 3-5min chart.

I may be easier to get it from somebody else who has ami :) .. the levels every day
 

vivektrader

In persuit of financial independence.
Thanks sir, regarding nifty futures only, which data feed do you suggest to be used with your afl? nestplus is not working for me.
 

pratapvb

Well-Known Member
Thanks sir, regarding nifty futures only, which data feed do you suggest to be used with your afl? nestplus is not working for me.
does not matter as long as it is 1min data preferrably and has volume data
 

XRAY27

Well-Known Member
Pratap ji !!!

Can we get vwap with SD lines same as intra in Daily charts...??
 

pratapvb

Well-Known Member
Pratap ji !!!

Can we get vwap with SD lines same as intra in Daily charts...??
only 5day vwap or such may work

vwap and SD lines will be difficult as it uses deviation of each bar from the avegarge price (vwap) to get SD and more bars the better

15min and hourly charts you could get approximations
 

Similar threads