.

Perfect Support Resistance Pivot - Amibroker AFL Code

Click Image To Enlarge. Please Rate And Comment.


_SECTION_BEGIN("pivot 1 hr");

TimeFrameSet( in15Minute );   
DH=Ref(H,-1); 
DL=Ref(L,-1);
DC=Ref(C,-1);

pd = (O+ DH+ DL + DC )/4;
sd1 = (2*pd)-DH;
sd2 = pd -(DH - DL);
sd3 = Sd1 - (DH-DL); 
rd1 = (2*pd)-DL;
rd2 = pd +(DH -DL);
rd3 = rd1 +(DH-DL);

H4 =  (dH - dL) * 1.1 / 2 + dC+3;
H3 = (dH - dL) * 1.1 / 4 + dC; 
h2 = (dH - dL) * 1.1 / 6 + dC;
H1 = (dH - dL) * 1.1 / 12 + dC;
L1 = dC - (dH - dL) * 1.1 / 12;
L2 = dC - (dH - dL) * 1.1 / 6;
L3 = dC - (dH - dL) * 1.1 / 4;
L4 = dC -3 - (dH - dL) * 1.1 / 2  ;
tgt_up = pd + 20;
tgt_dn = pd - 20;

Plot (pd,"Pivot",colorBlue,styleThick+styleDots);
Plot (H4," H4 ",35,8+16);
Plot (L4," L4 ",4,8+16);
Plot (tgt_up," tgt up ",colorWhite,8+16);
Plot (tgt_dn," tgt dn ",colorWhite,8+16);

//Plot (sd1," S1 ",4,8+16);
//Plot (Sd2," S2 ",4,8+16);
//Plot (Sd3," S3 ",4,8+16);

style = IIf(ParamList("Chart style", "styleCandle|styleBar")=="styleCandle",64,128+4);
Plot (C,Date ()+" close",1,style); //ENABLE THIS TO HAVE CANDLES AS WELL
_SECTION_END();



_SECTION_BEGIN("Fibo for all bars");

TimeFrameSet( inHourly ); 
DH=Ref(H,-1); 
DL=Ref(L,-1);
DC=Ref(C,-1);


pd = (O+ DH+ DL + DC )/4;
sd1 = (2*pd)-DH;
sd2 = pd -(DH - DL);
sd3 = Sd1 - (DH-DL); 
rd1 = (2*pd)-DL;
rd2 = pd +(DH -DL);
rd3 = rd1 +(DH-DL);



//Plot (pd,"Pivot",colorBlue,styleDots);
//Plot (rd1," R1 ",35,styleDots);
//Plot (rd2," R2 ",35,styleDots);
//Plot (rd3," R3 ",35,styleDots);

//Plot (sd1," S1 ",4,styleDots);
//Plot (Sd2," S2 ",4,styleDots);
//Plot (Sd3," S3 ",4,8+16);
/*
style = IIf(ParamList("Chart style", "styleCandle|styleBar")=="styleCandle",64,128+4);
Plot (C,Date ()+" close",1,style); //ENABLE THIS TO HAVE CANDLES AS WELL
*/
TimeFrameRestore();


Title = EncodeColor(colorWhite)+ "" + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
 "  - " + Date() +" - "
//+ WriteIf(Col_action==colorGreen, EncodeColor(colorGreen)+"stay LONG","")+ WriteIf(Col_action==colorRed, EncodeColor(colorRed)+"stay SHORT","")+  WriteIf(Col_action==colorBlack, EncodeColor(colorYellow)+"No Trend","")+"\n"
+ "Vol= "+ WriteVal(V) +WriteIf ( V > MA(V,26) ,EncodeColor(colorGreen)+"  UP "+ (V/MA(V,26))*100 + " %", EncodeColor(colorRed)+"  DOWN "+ (V/MA(V,26))*100 + " %")
+ EncodeColor(colorGreen)+   "\n R3 : "+ EncodeColor(colorWhite)+RD3
+ EncodeColor(colorGreen)+   "\n R2 : "+ EncodeColor(colorWhite)+RD2
+ EncodeColor(colorGreen)+   "\n R1 : "+ EncodeColor(colorWhite)+RD1+ EncodeColor(colorGreen)+   "`            Hi: "+ EncodeColor(colorWhite)+H
+ EncodeColor(colorBlue)+   "\n Pivot : "+ EncodeColor(colorWhite)+pd + EncodeColor(colorYellow)+   "`   Op: "+ EncodeColor(colorWhite)+O+ EncodeColor(colorAqua)+   "Cl: "+ EncodeColor(colorBrightGreen)+C
+ EncodeColor(colorRed)+   "\n S1 : "+ EncodeColor(colorWhite)+SD1+ EncodeColor(colorRed)+   "`            Lo: "+ EncodeColor(colorWhite)+L
+ EncodeColor(colorRed)+   "\n S2 : "+ EncodeColor(colorWhite)+SD2
+ EncodeColor(colorRed)+   "\n S3 : "+ EncodeColor(colorWhite)+SD3
;

_SECTION_END();
Previous Post Next Post