Afl required

johnnypareek

Well-Known Member
#11
Hi,

Well, Buy arrow is there, who is eating "sell" arrow. No sell arrow on chart. is it long only or what?

johnny



_SECTION_BEGIN("Ensign Volatility Stop");

// Ensign Volatility Stop
// get the multiple of 9 period EMA of ATR_Ensign
k=Param("multiplication factor", 1,0.5,5,0.1);

period=k*9;
VS_raw = 2.5 * EMA(ATR(1), period);

// for longs, VS line is below price
loline = VS_below_price = HHV(Close, period) - VS_raw;

// for shorts, VS line is above price
hiline = VS_above_price = LLV(Close, period) + VS_raw;
between = IIf (C < hiline AND C > loline, 1, 0);
up = IIf(C > hiline OR (H > Ref(H, -1) AND H > hiline), 1, 0);
dn = IIf(C < loline OR (L < Ref(L, -1) AND L < loline), 1, 0);
upcond = IIf(between AND BarsSince(up) < BarsSince(dn) , 1, 0);
dncond = IIf(between AND BarsSince(dn) < BarsSince(up) , 1, 0);
upline = IIf(up OR upcond, loline, Null);
dnline = IIf(dn OR dncond, hiline, Null);

Plot(upline, "", colorBlack, styleStaircase) ;
Plot(dnline, "", colorBlack, styleStaircase) ;

Buy=upline;
Sell=dnline;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Col = IIf(Buy,colorGreen,IIf(Sell,colorRed,colorBlack));
Plot(C, "", col, styleBar);

PlotShapes(Buy*shapeUpArrow,colorGreen);
PlotShapes(Sell*shapeDownArrow,colorRed);
 

johnnypareek

Well-Known Member
#12
hi,


Try this. Hmmm sell arrow too :)

_SECTION_BEGIN("Ensign Volatility Stop");
// Ensign Volatility Stop
// get the multiple of 9 period EMA of ATR_Ensign

k=Param("multiplication factor", 1,0.5,5,0.1);
period=k*9;

VS_raw = 2.5 * EMA(ATR(1), period);

// for longs, VS line is below price

loline = VS_below_price = HHV(Close, period) - VS_raw;

// for shorts, VS line is above price

hiline = VS_above_price = LLV(Close, period) + VS_raw;

between = IIf (C < hiline AND C > loline, 1, 0);

up = IIf(C > hiline OR (H > Ref(H, -1) AND H > hiline), 1, 0);

dn = IIf(C < loline OR (L < Ref(L, -1) AND L < loline), 1, 0);

upcond = IIf(between AND BarsSince(up) < BarsSince(dn) , 1, 0);

dncond = IIf(between AND BarsSince(dn) < BarsSince(up) , 1, 0);

upline = IIf(up OR upcond, loline, Null);

dnline = IIf(dn OR dncond, hiline, Null);

Plot(C, "", colorLightGrey, styleBar);

Plot(upline, "", colorGreen, styleStaircase) ;

Plot(dnline, "", colorRed, styleStaircase) ;
Buy=upline;
Sell=dnline;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
PlotShapes(Buy*shapeUpArrow,colorGreen);
PlotShapes(Sell*shapeDownArrow,colorRed);


/**** END ****/

_SECTION_BEGIN("Background");
SetChartOptions(0,chartShowArrows|chartShowDates);
if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g
(%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1
)));
}

SetChartBkColor(ParamColor("Outer panel color ",colorBlack)); // color of outer border
SetChartBkGradientFill( ParamColor("Inner panel color upper half",colorDarkTeal),
ParamColor("Inner panel color lower half",colorBlack)//color of inner panel
,ParamColor("behind Text Color", colorRed));
_SECTION_END();




enjoy
 
#13
Thank hitesh,


You give me good afl. But i want one small change in these afl when buy call is given bar color is green but after next bar color is black. it is possible the bar color is continue green till next sell signal. means only two color bar one is green when buy call and second is red when sell call no black bar show.
 
#14
Thank hitesh,


You give me good afl. But i want one small change in these afl when buy call is given bar color is green but after next bar color is black. it is possible the bar color is continue green till next sell signal. means only two color bar one is green when buy call and second is red when sell call no black bar show.



_SECTION_BEGIN("Ensign Volatility Stop");

// Ensign Volatility Stop
// get the multiple of 9 period EMA of ATR_Ensign
k=Param("multiplication factor", 1,0.5,5,0.1);

period=k*9;
VS_raw = 2.5 * EMA(ATR(1), period);

// for longs, VS line is below price
loline = VS_below_price = HHV(Close, period) - VS_raw;

// for shorts, VS line is above price
hiline = VS_above_price = LLV(Close, period) + VS_raw;
between = IIf (C < hiline AND C > loline, 1, 0);
up = IIf(C > hiline OR (H > Ref(H, -1) AND H > hiline), 1, 0);
dn = IIf(C < loline OR (L < Ref(L, -1) AND L < loline), 1, 0);
upcond = IIf(between AND BarsSince(up) < BarsSince(dn) , 1, 0);
dncond = IIf(between AND BarsSince(dn) < BarsSince(up) , 1, 0);
upline = IIf(up OR upcond, loline, Null);
dnline = IIf(dn OR dncond, hiline, Null);

Plot(upline, "", colorBlack, styleStaircase) ;
Plot(dnline, "", colorBlack, styleStaircase) ;

Buy=upline;
Sell=dnline;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Col = IIf(Buy,colorGreen,IIf(Sell,colorRed,colorBlack));
Plot(C, "", col, styleBar);

PlotShapes(Buy*shapeUpArrow,colorGreen);
PlotShapes(Sell*shapeDownArrow,colorRed);
 

hitesh

Active Member
#15
Thank hitesh,


You give me good afl. But i want one small change in these afl when buy call is given bar color is green but after next bar color is black. it is possible the bar color is continue green till next sell signal. means only two color bar one is green when buy call and second is red when sell call no black bar show.
_SECTION_BEGIN("Ensign Volatility Stop");

// Ensign Volatility Stop
// get the multiple of 9 period EMA of ATR_Ensign
k=Param("multiplication factor", 1,0.5,5,0.1);

period=k*9;
VS_raw = 2.5 * EMA(ATR(1), period);

// for longs, VS line is below price
loline = VS_below_price = HHV(Close, period) - VS_raw;

// for shorts, VS line is above price
hiline = VS_above_price = LLV(Close, period) + VS_raw;
between = IIf (C < hiline AND C > loline, 1, 0);
up = IIf(C > hiline OR (H > Ref(H, -1) AND H > hiline), 1, 0);
dn = IIf(C < loline OR (L < Ref(L, -1) AND L < loline), 1, 0);
upcond = IIf(between AND BarsSince(up) < BarsSince(dn) , 1, 0);
dncond = IIf(between AND BarsSince(dn) < BarsSince(up) , 1, 0);
upline = IIf(up OR upcond, loline, Null);
dnline = IIf(dn OR dncond, hiline, Null);

Plot(upline, "", colorBlack, styleStaircase) ;
Plot(dnline, "", colorBlack, styleStaircase) ;

Buy=upline;
Sell=dnline;

Col = IIf(Buy,colorGreen,IIf(Sell,colorRed,colorBlack));

Plot(C, "", col, styleBar);

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorBrightGreen, colorRed ),0, IIf( Buy, Low, High ) );
 
#16
Hi Hitesh ,


Fantastic work, Thanks very Much. :clapping:


Can you give password to any afl. if i want to give one formula to any person but i want to protect it with password so it is possibale.
 
#18
hi hitesh,


i can do these here i sent new afl with open high low close vlaue.



_SECTION_BEGIN("Ensign Volatility Stop");

// Ensign Volatility Stop
// get the multiple of 9 period EMA of ATR_Ensign

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
k=Param("multiplication factor", 1,0.5,5,0.1);

period=k*5;
VS_raw = 2.2 * EMA(ATR(1), period);

// for longs, VS line is below price
loline = VS_below_price = HHV(Close, period) - VS_raw;

// for shorts, VS line is above price
hiline = VS_above_price = LLV(Close, period) + VS_raw;
between = IIf (C < hiline AND C > loline, 1, 0);
up = IIf(C > hiline OR (H > Ref(H, -1) AND H > hiline), 1, 0);
dn = IIf(C < loline OR (L < Ref(L, -1) AND L < loline), 1, 0);
upcond = IIf(between AND BarsSince(up) < BarsSince(dn) , 1, 0);
dncond = IIf(between AND BarsSince(dn) < BarsSince(up) , 1, 0);
upline = IIf(up OR upcond, loline, Null);
dnline = IIf(dn OR dncond, hiline, Null);

Buy=upline;
Sell=dnline;

Col = IIf(Buy,colorGreen,IIf(Sell,colorRed,colorBlack));

Plot(C, "", col, styleBar | styleThick );

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorBrightGreen, colorRed ),0, IIf( Buy, Low, High ) );
 
#20
Hi friedns,

I want to change these support and Resistance color.
I want support color is green and resistance color is red.
If you can pls try these.

_SECTION_BEGIN("Support_and_Resistance");
/* SUPPORT AND RESISTANCE */
/* AFL Code - Prakash Shenoi */
LB= Param("Look Back Periods",10,1,30,1);
R=ValueWhen(Cross(MA(C,LB),C),HHV(H,LB),1);
S=ValueWhen(Cross(C,MA(C,LB)),LLV(L,LB),1);
Color=IIf(O>C,colorWhite,colorWhite);
Plot (R,"Resz",22,8+16);
Plot (s,"Supp",19,8+16);
GraphXSpace=4;
_SECTION_END();
 

Similar threads