Friday, 5 September 2014
Dinamic Support resistance with Heiken Ashi flower Afl
// https://www.facebook.com/StocKanalysisBd?ref=hl
Dinamic Support resistance with Heiken Ashi flower Afl
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("\\c02 {{NAME}} || {{INTERVAL}} {{DATE}} || Open %g,High: %g,Low: %g, Close: %g (%.1f%%)
Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}",
O, H, L, C, SelectedValue( ROC( C, 1 )) ));
barcolor =IIf(C>O, ParamColor("Up candlestick", colorBrightGreen ), ParamColor("Down candlestick", colorOrange ));
_SECTION_BEGIN("o");
MaxGraph = 12;
BuyOffSet = 18;
SellOffset = BuyOffSet;
RegLength = 5;
BuyATRPeriod = 2;
SellATRPeriod = BuyATRPeriod;
ATRMultiplier = 0.5;
G8 = HHV(H-ATRMultiplier*ATR(BuyATRPeriod),BuyOffset);
G9 = LLV(L+ATRMultiplier*ATR(SellATRPeriod),SellOffset);
ave=(G8+G9)/2;
nn=21;
mmm=120;
TYP=(High + Low + 2*Close)/4;
CI=(TYP-MA(TYP,14))/(0.015*StDev(TYP,14));
CCCI=EMA(CI,5)+mmm;
Hh=HHV(H,nn);
Ll=LLV(L,nn);
MM=(Hh+Ll)/2;
CCCC=EMA(CCCI*(Hh-Ll)/(2*mmm)+Ll,5);
Mbuy = (Cccc>Ref(Cccc,-1) AND Ref(Cccc,-1)<Ref(Cccc,-2) AND Cccc<ave) OR Cross(Cccc,Ll) OR Cross(Cccc,G9);
MSell= (Cccc<Ref(Cccc,-1) AND Ref(Cccc,-1)>Ref(Cccc,-2) AND Cccc>ave) OR Cross(Hh,Cccc) OR Cross(G8,Cccc);
PlotShapes( IIf( MBuy, shapeHollowSmallCircle, shapeNone ), colorBlue, 0, yposition = L, offset = -25 );
PlotShapes( IIf( MSell, shapeHollowSmallCircle, shapeNone ), colorYellow, 0, yposition = H, offset = 25 );
_SECTION_END();
BuyOffSet = 18;
SellOffset = 18;
RegLength = 5;
BuyATRPeriod = 2;
SellATRPeriod = BuyATRPeriod;
ATRMultiplier = 0.5;
G8 = HHV(H-ATRMultiplier*ATR(BuyATRPeriod),BuyOffset);
G9 = LLV(L+ATRMultiplier*ATR(SellATRPeriod),SellOffset);
ave=(G8+G9)/2;
CC = EMA((Open+High+Low+Close)/4,3);
CO = EMA((Ref(Open,-1) + Ref(CC,-1))/2,3);
Temp = Max(High,CO);
CH = EMA(Max(Temp, CC),3);
Temp = Min(Low,CO);
CL = EMA(Min(Temp, CC),3);
Prd1=Param("ATR Period",4,1,20,1);
Prd2=Param("Look Back",7,1,20,1);
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);
// Bar fill color
Show_color = ParamToggle("Display CandleColor", "No|Yes", 1);
r1 = Param( "ColorFast avg", 5, 2, 200, 1 );
r2 = Param( "ColorSlow avg", 10, 2, 200, 1 );
r3 = Param( "ColorSignal avg", 5, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
mycolor=IIf(m1<0 AND m1>s1, colorWhite,IIf(m1>0 AND m1>s1,colorLightBlue,IIf(m1>0 AND m1<s1,colorOrange,colorRed)));
barColor=IIf(Mbuy ,colorBrightGreen,IIf(Msell,colorDarkRed,mycolor));
if(Show_color)
{
ColorHighliter = barColor;
SetBarFillColor( ColorHighliter );
}
barColor1=IIf(C>Green ,colorBlue,IIf(C < RED,colorRed,colorLightYellow));
Barcolor2=IIf(C>Green, colorLightBlue,IIf(C < RED, colorRed, colorWhite));
barColor=IIf(Mbuy ,colorBrightGreen,IIf(Msell,colorDarkRed,barcolor2));
SetBarFillColor(barcolor);
PlotOHLC( CO,CH,CL,CC, "Price", barcolor1, styleCandle );
nn=14;
mmm=120;
Hh=HHV(CH,nn);
Ll=LLV(CL,nn);
Hh1=HHV(IIf(CC>CO,CC,CO),nn);
Ll1=LLV(IIf(CC<CO,CC,CO),nn);
MM=(Hh+Ll)/2;
Plot(HHV(Hh,40),"Resistance",colorRed,styleLine|styleThick);
Plot(LLV(Ll,40),"Support",colorGrey40,styleLine|styleThick);
Plot(Hh,"Resistance",colorDarkRed,styleLine|styleThick);
Plot(Ll,"Support",colorGreen,styleLine|styleThick);
Plot(Hh1,"Resistance",11,styleLine);
Plot(Ll1,"Support",colorBrightGreen,styleLine);
_SECTION_BEGIN("9Trading2");
function Rise( Pd, perd, Pl, perl )
{
MAD = DEMA(Pd,perd);
MAL = LinearReg(Pl,perl);
CondR = ROC(MAD,1)>0 AND ROC(MAL,1)>0;
CondF = ROC(MAD,1)<0 AND ROC(MAL,1)<0;
R[0] = C[0]>(H[0]+L[0])/2;
for(i=1;i<BarCount;i++)
{
if( CondR[i] )
{
R[i] = 1;
}
else
{
if( CondF[i] )
{
R[i] = 0;
}
else
{
R[i] = R[i-1];
}
}
}
return R;
}
PrD = C;
PrL = H/2+L/2;
PrdD = PrdL = PrdM = Param("Prd",12,2,40,1);
permax = Max(prdd,prdl);
Rs = IIf( BarIndex()<permax, 0, Rise(PrD, PrdD, PrL, PrdL) );
Fs = IIf( BarIndex()<permax, 0, 1-Rs );
Confirm = MA(C,prdm);
function DirBar( dr, df )
{
B[0] = 0;
for(i=1;i<BarCount;i++)
{
if( dr[i-1] && df[i] )
{
B[i] = 1;
}
else
{
if( df[i-1] && dr[i] )
{
B[i] = 1;
}
else
{
B[i] = B[i-1] + 1;
}
}
}
return B;
}
Bs = DirBar( Rs, Fs );
Direction = ROC(Confirm,1) > 0 AND ROC(Confirm,5) > 0;
Downward = ROC(Confirm,1) < 0 AND ROC(Confirm,5) < 0;
Select = Rs AND Ref(Fs,-1);
Caution = Fs AND Ref(Rs,-1);
PlotShapes( shapeSmallCircle* select, colorBlue, 0, CL, -2 );
PlotShapes( shapeSmallCircle* Caution, colorRed, 0, CH,2 );
_SECTION_END();
_SECTION_BEGIN("ATR Trailing SL");
ka = 1;
Pero = Param("ATR", 4, 1, 30, 0.50);
HACLOSE=(O+H+L+C)/4;
j=Haclose;
f=ATR(Pero);
rfsctor = WMA(f, Pero);
revers = ka * rfsctor;
Trend = 1;
NW[0] = 0;
for(i = 1; i < BarCount; i++)
{
if(Trend[i-1] == 1)
{
if(j[i] < NW[i-1])
{
Trend[i] = -1;
NW[i] = j[i] + Revers[i];
}
else
{
Trend[i] = 1;
if((j[i] - Revers[i]) > NW[i-1])
{
NW[i] = j[i] - Revers[i];
}
else
{
NW[i] = NW[i-1];
}
}
}
if(Trend[i-1] == -1)
{
if(j[i] > NW[i-1])
{
Trend[i] = 1;
NW[i] = j[i] - Revers[i];
}
else
{
Trend[i] = -1;
if((j[i] + Revers[i]) < NW[i-1])
{
NW[i] = j[i] + Revers[i];
}
else
{
NW[i] = NW[i-1];
}
}
}
}
Buy1= C>NW;
Sell1=C<NW;
Buy2 = ExRem(Buy1, Sell1);
Sell2 = ExRem(Sell1, Buy1);
PlotShapes(shapeHollowUpArrow * Buy2, colorGreen,0,L, - 40);
PlotShapes(shapeHollowDownArrow * Sell2, colorRed,0,H, - 40);
_SECTION_END();
_SECTION_BEGIN("Volatility");
Pero = Param("Volatility", 4, 1, 30, 0.50);
A = HHV(C,Pero);
B = HHV(O,Pero);
Cat = HHV(H,Pero);
E = LLV(C,Pero);
F = LLV(O,Pero);
Hat = LLV(L,Pero);
BO1 = IIf(A>B, A, B);
BO = IIf(BO1 >Cat, BO1, Cat);
BD1 = IIf(E <F, E, F);
BD = IIf(BD1 <Hat, BD1, Hat);
Buy11 = C > Ref(BO,-1);
Sell22 = C < Ref(BD,-1);
Buy2 = ExRem(Buy11, Sell22);
Sell2 = ExRem(Sell22, Buy11);
PlotShapes(shapeHollowUpArrow * Buy2, colorGreen,0,CL, - 33);
PlotShapes(shapeHollowDownArrow * Sell2, colorRed,0,CH, -33);
_SECTION_END();
_SECTION_BEGIN("Stochastic");
StochKval = StochK(10,5);
StochDval = StochD(10,5,5);
SSbuy = Cross(StochK(10,5), StochD(10,5,5));
SSsell = Cross (StochD(10,5,5), StochK(10,5));
Filter = SSbuy OR SSsell;
PlotShapes(IIf(SSbuy AND StochKval < 26, shapeHollowSmallSquare,shapeNone), colorBrightGreen,0,CL, - 10);
PlotShapes(IIf(SSbuy AND StochKval < 26,shapeSmallCircle, shapeNone),colorBrightGreen,0,CL, - 10);
PlotShapes(IIf(SSbuy AND StochKval > 26, shapeSmallSquare,shapeNone), colorBrightGreen,0,CL, - 10);
PlotShapes(IIf(SSbuy AND StochKval > 26,shapeSmallCircle, shapeNone),colorDarkGreen,0,CL, - 10);
PlotShapes(shapeHollowSmallSquare * SSsell, colorRed,0,CH, 10);
PlotShapes(shapeSmallCircle * SSsell, colorRed,0,CH, 10);
_SECTION_END();
_SECTION_BEGIN("Text");
Font = ParamList("Font:","Calibri|Bauhaus 93|Arial|Futura|Tahoma|Times New Roman");
FontColor=ParamColor("FontColor", colorOrange);
FontSize=Param("FontSize", 12,1,100);
TextPosition1=Param("TextPosition1", 2,1,800);
TextPosition2=Param("TextPosition2", 30,1,1000);
GfxSelectFont(font, FontSize, 800);
GfxSetBkMode(1);
GfxSetTextColor(Fontcolor);
GfxTextOut("", TextPosition1, TextPosition2);
GfxSetBkColor(colorWhite);
_SECTION_END();
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Thanks