Thursday, 11 June 2020

123 pattern (as part of uncompleted ABCD pattern)

 123 pattern (as part of uncompleted ABCD pattern)

Amibroker AFL LOOKS LIKE
 








grid_day = IIf(Day()!=Ref(Day(),-1),1,0);

RequestTimedRefresh(0.1,True);
xx=BarIndex();x=xx;Lx=LastValue(x);
nbar=Param("N Pivot Bars",5,2,50,1);
tf=Param("Time Frame (min)",5,0.01,1440,1);tfrm=in1Minute*tf;
CleanPivots=ParamToggle("Use Clean Pivots","Off|On",1);
PivotSymmetry=ParamToggle("Use Symmetric Pivots","Off|On",0);
dispbe123=ParamToggle("Display bearish 123","Off|On",1);
dispbu123=ParamToggle("Display bullish 123","Off|On",1);
dispbeRetraceValues=ParamToggle("Display retrace value (Bearish)","Off|On",1);
dispbuRetraceValues=ParamToggle("Display retrace value (Bullish)","Off|On",1);
dispLabels=ParamToggle("Display Labels","Off|On",1);
entryType=ParamToggle("Entry Type","Regular|Agressive",1);
signalRangeCheck=ParamToggle("Signal Entry Range Limit","Off|On",1);
extendRange=Param("Extended entry range",100,0,500,1);
minRetrace=Param("Retrace Minimum",0.382,0,2,0.01);
maxRetrace=Param("Retrace Maximum",0.88,0,6,0.01);

TimeFrameSet(tfrm);
if(PivotSymmetry)
{
    fc=1;
    pk=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)<=H;
    tr=L<Ref(LLV(L,nbar*fc),-1) AND Ref(LLV(L,nbar),nbar)>=L;
}
else
{
    fc=2;
    pk=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)<=H;
    tr=L<Ref(LLV(L,nbar*fc),-1) AND Ref(LLV(L,nbar),nbar)>=L;
}

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
px3=ValueWhen(pk,x,3); tx3=ValueWhen(tr,x,3);
ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);
ph3=ValueWhen(pk,H,3); tl3=ValueWhen(tr,L,3);

if(CleanPivots)
{
    tr=IIf((tr==1 AND pk==1) AND px2<tx2 AND Lx!=BarCount-1,False,tr);
    pk=IIf((tr==1 AND pk==1) AND px2>tx2 AND Lx!=BarCount-1,False,pk);
   
    px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
    px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
    px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
    px3=ValueWhen(pk,x,3); tx3=ValueWhen(tr,x,3);   
    ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
    ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
    ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);
    ph3=ValueWhen(pk,H,3); tl3=ValueWhen(tr,L,3);   
   
    tr=IIf(tr AND ((tx0<px0 AND tl1>tl0) OR (tx2>px1 AND tl1>tl2) OR (px0==px1 AND tl1>tl0) OR (tl1>tl0 AND px0==tx0)),False,tr);
    pk=IIf(pk AND ((px0<tx0 AND ph1<ph0) OR (px2>tx1 AND ph1<ph2) OR (tx0==tx1 AND ph1<ph0) OR (ph1<ph0 AND px0==tx0)),False,pk);

    px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
    px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
    px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
    px3=ValueWhen(pk,x,3); tx3=ValueWhen(tr,x,3);
    ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
    ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
    ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);
    ph3=ValueWhen(pk,H,3); tl3=ValueWhen(tr,L,3);   

    tr=IIf(tr AND ((tx0<px0 AND tl1>tl0) OR (tx2>px1 AND tl1>tl2) OR (px0==px1 AND tl1>tl0) OR (tl1>tl0 AND px0==tx0)),False,tr);
    pk=IIf(pk AND (((px0<tx0 AND ph1<ph0) OR px2>tx1 AND ph1<ph2) OR (tx0==tx1 AND ph1<ph0) OR (ph1<ph0 AND px0==tx0)),False,pk);

    px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
    px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
    px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
    px3=ValueWhen(pk,x,3); tx3=ValueWhen(tr,x,3);
    ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
    ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
    ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);
    ph3=ValueWhen(pk,H,3); tl3=ValueWhen(tr,L,3);   
}
pkh=IIf(pk,H,Null);
trl=IIf(tr,L,Null);
TimeFrameRestore();
fact=Nz(Max(tfrm/60,Interval()/60)/(Interval()/60));
if(fact==0)fact=1;
Lkbk=Nz(tfrm/Interval());
if(Lkbk>1)
{
    pk=TimeFrameExpand(pk,tfrm,expandFirst);
    pkh=TimeFrameExpand(pkh,tfrm,expandFirst);
    pkhs=IIf(!IsEmpty(pkh),1,0);pkhs=pkhs-Ref(pkhs,-1);
    pk=pk AND H==pkh;
    cond1=Sum(pk,BarsSince(pkhs==1)+1)==1 AND pk;
    pk=pk AND cond1;
   
    tr=TimeFrameExpand(tr,tfrm,expandFirst);   
    trl=TimeFrameExpand(trl,tfrm,expandFirst);
    trls=IIf(!IsEmpty(trl),1,0);trls=trls-Ref(trls,-1);
    tr=tr AND L==trl;
    cond1=Sum(tr,BarsSince(trls==1)+1)==1 AND tr;
    tr=tr AND cond1;
   
    px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
    px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
    px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
    px3=ValueWhen(pk,x,3); tx3=ValueWhen(tr,x,3);
    ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
    ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
    ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);
    ph3=ValueWhen(pk,H,3); tl3=ValueWhen(tr,L,3);
}

ll=tr AND tl1<tl2;
hl=tr AND tl1>tl2;
hh=pk AND ph1>ph2;
lh=pk AND ph1<ph2;
dt=pk AND ph1==ph2;
db=tr AND tl1==tl2;

ll_h=IIf(ll,1,0);
hl_h=IIf(hl,2,0);
hh_h=IIf(hh,3,0);
lh_h=IIf(lh,4,0);
dt_h=IIf(dt,5,0);
db_h=IIf(db,6,0);

combi=ll_h+hl_h+lh_h+hh_h+dt_h+db_h;

t0=ValueWhen(combi,combi,0);
t1=ValueWhen(combi,combi,1);
t2=ValueWhen(combi,combi,2);
t3=ValueWhen(combi,combi,3);
t4=ValueWhen(combi,combi,4);
t5=ValueWhen(combi,combi,5);

// bearisch 123 pattern
be123=pk AND t1==4 AND t2==2;
beAx=ValueWhen(be123,tx2);beAy=ValueWhen(be123,tl2);
beBx=ValueWhen(be123,px2);beBy=ValueWhen(be123,ph2);
beCx=ValueWhen(be123,tx1);beCy=ValueWhen(be123,tl1);
beDx=ValueWhen(be123,px1);beDy=ValueWhen(be123,ph1);
beRetrace=(beBy-beCy)/(beBy-beAy);
be123=be123 AND beRetrace>minRetrace AND beRetrace<maxRetrace AND beDy>beCy;
rr=BarsSince(be123)>=0 AND BarsSince(be123)<extendRange;
idx=IIf(rr,xx-ValueWhen(be123,beCx),Null);
if(entryType) aa=(beCy-beAy)/(beCx-beAx);else aa=0;bb=beCy;
aa=ValueWhen(be123,aa);bb=ValueWhen(be123,bb);
beEx=ValueWhen(be123,px1);ii=px1-beCx;beEy=aa*ii+bb;
be123=be123 AND beEy<beDy;
beTrendline=IIf(idx,aa*idx+bb,Null);beValidSignalArea=Flip(be123,Ref(tr,-1));
if(signalRangeCheck) beTrendline=IIf(beValidSignalArea,beTrendline,Null);
Short=Cross(beTrendline,C) AND !IsEmpty(beTrendline);Short=Ref(Short,-1);ShortPrice=O;
Short=ExRem(Short,be123);Sell=0;

// bullish 123 pattern
bu123=tr AND t1==2 AND t2==4;
buAx=ValueWhen(bu123,px2);buAy=ValueWhen(bu123,ph2);
buBx=ValueWhen(bu123,tx2);buBy=ValueWhen(bu123,tl2);
buCx=ValueWhen(bu123,px1);buCy=ValueWhen(bu123,ph1);
buDx=ValueWhen(bu123,tx1);buDy=ValueWhen(bu123,tl1);
buRetrace=(buCy-buBy)/(buAy-buBy);
bu123=bu123 AND buRetrace>minRetrace AND buRetrace<maxRetrace AND buDy<buCy;;
rr=BarsSince(bu123)>=0 AND BarsSince(bu123)<extendRange;
idx=IIf(rr,xx-ValueWhen(bu123,buCx),Null);
if(entryType) aa=(buCy-buAy)/(buCx-buAx);else aa=0;bb=buCy;
aa=ValueWhen(bu123,aa);bb=ValueWhen(bu123,bb);
buEx=ValueWhen(bu123,tx1);ii=tx1-buCx;buEy=aa*ii+bb;
bu123=bu123 AND buEy>buDy;
buTrendline=IIf(idx,aa*idx+bb,Null);buValidSignalArea=Flip(bu123,Ref(pk,-1));
if(signalRangeCheck) buTrendline=IIf(buValidSignalArea,buTrendline,Null);
Buy=Cross(C,buTrendline) AND !IsEmpty(buTrendline);
Buy=Ref(Buy,-1);BuyPrice=O;
Buy=ExRem(Buy,bu123);Cover=0;

GraphXSpace=5;
SetChartBkColor(ColorRGB(0,0,0));SetChartOptions(0,chartShowDates);
SetBarFillColor(IIf(C>O,colorBlue,IIf(C<=O,colorRed,colorLightGrey)));
Plot(C,"Price",IIf(C>O,colorSkyblue,IIf(C<=O,colorGold,colorLightGrey)),64,0,0,0,0);
Plot(pkh,"",colorRed,styleThick,0,0,0,-1);
Plot(trl,"",colorBrightGreen,styleThick,0,0,0,-1);
PlotShapes(shapeSmallCircle*tr,IIf(Lx-ValueWhen(tr,x)>nbar*fact,colorBrightGreen,colorWhite),0,L,-10);
PlotShapes(shapeSmallCircle*pk,IIf(Lx-ValueWhen(pk,x)>nbar*fact,colorOrange,colorWhite),0,H,10);

qq=Interval()/60;
if(qq < 60){tf=" min";tt=qq;}
else if(qq >= 60 AND qq < 1440){tf=" hrs";tt=qq/60;}
else if(qq >= 1440){tf=" days";tt=(qq/60)/24;}
qq=Max(tfrm/60,Interval()/60);
if(qq < 60){tfa=" min";tta=qq;}
else if(qq >= 60 AND qq < 1440){tfa=" hrs";tta=qq/60;}
else if(qq >= 1440){tfa=" days";tta=(qq/60)/24;}

Title =EncodeColor(colorWhite)+ Name() + " | " + Date()+ " | "+ Interval(2)+
"\nNbar: " + nbar +
"\nChart TF: " + tt + tf +
"\nTrend TF: " + tta + tfa;

abcdy_up=27;
abcdy_dn=15;
function GetVisibleBarCount()
{
    lvb=Status("lastvisiblebar");
    fvb=Status("firstvisiblebar");
    return Min(lvb-fvb,BarCount-fvb);
}
function GfxConvertPixelsToBarX(Pixels)
{
    lvb=Status("lastvisiblebar");
    fvb=Status("firstvisiblebar");
    pxchartleft=Status("pxchartleft");
    pxchartwidth=Status("pxchartwidth");
    fac=pxchartwidth/Pixels;
    bar=(lvb-fvb)/fac;
    return bar;
}
function GfxConvertPixelToValueY(Pixels)
{
    local Miny,Maxy,pxchartbottom,pxchartheight;
    Miny=Status("axisminy");
    Maxy=Status("axismaxy");
    pxchartbottom=Status("pxchartbottom");
    pxchartheight=Status("pxchartheight");
    fac=pxchartheight/Pixels;
    Value=(Maxy-Miny)/fac;
    return Value;
}
function GfxConvertBarToPixelX(bar)
{
    lvb=Status("lastvisiblebar");
    fvb=Status("firstvisiblebar");
    pxchartleft=Status("pxchartleft");
    pxchartwidth=Status("pxchartwidth");
    return pxchartleft+bar*pxchartwidth/(lvb-fvb+1);
}
function GfxConvertValueToPixelY(value)
{
    local Miny,Maxy,pxchartbottom,pxchartheight;
    Miny=Status("axisminy");
    Maxy=Status("axismaxy");
    pxchartbottom=Status("pxchartbottom");
    pxchartheight=Status("pxchartheight");
    return pxchartbottom-floor(0.5+(Value-Miny)*pxchartheight/(Maxy-Miny));
}
AllVisibleBars=GetVisibleBarCount();
fvb=Status("firstvisiblebar");
abcdy_up=GfxConvertPixelToValueY(abcdy_up);
abcdy_dn=GfxConvertPixelToValueY(abcdy_dn);

for(i=0;i<AllVisibleBars;i++)
{
    if(ll[i+fvb] AND dispLabels)
    {
        lvix=i+fvb;GfxSelectFont("Tahoma",8,500); GfxSetBkMode(1);
        GfxSetTextColor(colorYellow);GfxTextOut("ll",
        GfxConvertBarToPixelX(i)-3,GfxConvertValueToPixelY(L[lvix]-abcdy_dn));
    }
    if(hl[i+fvb] AND dispLabels)
    {
        lvix=i+fvb;GfxSelectFont("Tahoma",8,500); GfxSetBkMode(1);
        GfxSetTextColor(colorYellow);GfxTextOut("hl",
        GfxConvertBarToPixelX(i)-3,GfxConvertValueToPixelY(L[lvix]-abcdy_dn));
    }   
    if(db[i+fvb] AND dispLabels)
    {
        lvix=i+fvb;GfxSelectFont("Tahoma",8,500); GfxSetBkMode(1);
        GfxSetTextColor(colorYellow);GfxTextOut("db",
        GfxConvertBarToPixelX(i)-3,GfxConvertValueToPixelY(L[lvix]-abcdy_dn));
    }       
    if(hh[i+fvb] AND dispLabels)
    {
        lvix=i+fvb;GfxSelectFont("Tahoma",8,500); GfxSetBkMode(1);
        GfxSetTextColor(colorYellow);GfxTextOut("hh",
        GfxConvertBarToPixelX(i)-5,GfxConvertValueToPixelY(H[lvix]+abcdy_up));
    }   
    if(lh[i+fvb] AND dispLabels)
    {
        lvix=i+fvb;GfxSelectFont("Tahoma",8,500); GfxSetBkMode(1);
        GfxSetTextColor(colorYellow);GfxTextOut("lh",
        GfxConvertBarToPixelX(i)-5,GfxConvertValueToPixelY(H[lvix]+abcdy_up));
    }   
    if(dt[i+fvb] AND dispLabels)
    {
        lvix=i+fvb;GfxSelectFont("Tahoma",8,500); GfxSetBkMode(1);
        GfxSetTextColor(colorYellow);GfxTextOut("dt",
        GfxConvertBarToPixelX(i)-5,GfxConvertValueToPixelY(H[lvix]+abcdy_up));
    }       
    if(be123[i+fvb] AND dispbe123)
    {
        GfxSetOverlayMode(1);
        GfxSelectPen(25,1);
        GfxSelectSolidBrush(25);    
        lvix=i+fvb;
        GfxSetBkMode(1);GfxSetOverlayMode(1);GfxSelectPen(25,1,1);
        GfxMoveTo(GfxConvertBarToPixelX(i-(beDx[lvix]-beCx[lvix])),GfxConvertValueToPixelY(beCy[lvix]));
        GfxLineTo(GfxConvertBarToPixelX(i),GfxConvertValueToPixelY(beDy[lvix]));
        GfxMoveTo(GfxConvertBarToPixelX(i-(beDx[lvix]-beBx[lvix])),GfxConvertValueToPixelY(beBy[lvix]));
        GfxLineTo(GfxConvertBarToPixelX(i),GfxConvertValueToPixelY(beDy[lvix]));
        GfxSelectPen(25,1,0);
        GfxMoveTo(GfxConvertBarToPixelX(i-(beDx[lvix]-beAx[lvix])),GfxConvertValueToPixelY(beAy[lvix]));
        GfxLineTo(GfxConvertBarToPixelX(i-(beDx[lvix]-beBx[lvix])),GfxConvertValueToPixelY(beBy[lvix]));       
        GfxMoveTo(GfxConvertBarToPixelX(i-(beDx[lvix]-beAx[lvix])),GfxConvertValueToPixelY(beAy[lvix]));
        GfxLineTo(GfxConvertBarToPixelX(i-(beDx[lvix]-beCx[lvix])),GfxConvertValueToPixelY(beCy[lvix]));   
        GfxMoveTo(GfxConvertBarToPixelX(i-(beDx[lvix]-beBx[lvix])),GfxConvertValueToPixelY(beBy[lvix]));
        GfxLineTo(GfxConvertBarToPixelX(i-(beDx[lvix]-beCx[lvix])),GfxConvertValueToPixelY(beCy[lvix]));       
        GfxSelectFont("Tahoma",10,500);GfxSetBkMode(1);
        GfxSetTextColor(25);GfxTextOut("1",GfxConvertBarToPixelX(i-(beDx[lvix]-beBx[lvix]))-7,GfxConvertValueToPixelY(beBy[lvix]+1.5*abcdy_up));
        GfxSetTextColor(25);GfxTextOut("2",GfxConvertBarToPixelX(i-(beDx[lvix]-beCx[lvix]))-7,GfxConvertValueToPixelY(beCy[lvix]-1.6*abcdy_dn));
        GfxSetTextColor(25);GfxTextOut("3",GfxConvertBarToPixelX(i-(beDx[lvix]-beDx[lvix]))-7,GfxConvertValueToPixelY(beDy[lvix]+1.5*abcdy_up));
        Plot(LineArray(beCx[lvix],beCy[lvix],beEx[lvix],beEy[lvix],0,True ),"",colorOrange,styleDashed);
        Plot(beTrendline,"",colorOrange,styleDots|styleNoLine,0,0,0,0);
        PlotShapes(IIf(Short,shapeDownArrow,shapeNone),colorRed,0,H,IIf(Short AND Sell,-30,-15));   
        //PlotShapes(IIf(Short,shapeSmallCircle,shapeNone),colorWhite,0,ShortPrice,0);   
        if(dispbeRetraceValues)
        {
            GfxSelectFont("Tahoma",8,650); GfxSetBkMode(2);GfxSetOverlayMode(1);GfxSetBkColor(colorDarkRed);GfxSetTextColor(colorWhite);
            GfxTextOut(""+Prec(beRetrace[lvix],2),GfxConvertBarToPixelX(i-(beDx[lvix]-(beAx[lvix]+beCx[lvix])/2)),GfxConvertValueToPixelY((beAy[lvix]+beCy[lvix])/2));
        }           
    }
    if(bu123[i+fvb] AND dispbu123)
    {
        GfxSetOverlayMode(1);
        GfxSelectPen(51,1);
        GfxSelectSolidBrush(51);    
        lvix=i+fvb;
        GfxSetBkMode(1);GfxSetOverlayMode(1);GfxSelectPen(51,1,1);
        GfxMoveTo(GfxConvertBarToPixelX(i-(buDx[lvix]-buCx[lvix])),GfxConvertValueToPixelY(buCy[lvix]));
        GfxLineTo(GfxConvertBarToPixelX(i),GfxConvertValueToPixelY(buDy[lvix]));
        GfxMoveTo(GfxConvertBarToPixelX(i-(buDx[lvix]-buBx[lvix])),GfxConvertValueToPixelY(buBy[lvix]));
        GfxLineTo(GfxConvertBarToPixelX(i),GfxConvertValueToPixelY(buDy[lvix]));
        GfxSelectPen(51,1,0);
        GfxMoveTo(GfxConvertBarToPixelX(i-(buDx[lvix]-buAx[lvix])),GfxConvertValueToPixelY(buAy[lvix]));
        GfxLineTo(GfxConvertBarToPixelX(i-(buDx[lvix]-buBx[lvix])),GfxConvertValueToPixelY(buBy[lvix]));       
        GfxMoveTo(GfxConvertBarToPixelX(i-(buDx[lvix]-buAx[lvix])),GfxConvertValueToPixelY(buAy[lvix]));
        GfxLineTo(GfxConvertBarToPixelX(i-(buDx[lvix]-buCx[lvix])),GfxConvertValueToPixelY(buCy[lvix]));   
        GfxMoveTo(GfxConvertBarToPixelX(i-(buDx[lvix]-buBx[lvix])),GfxConvertValueToPixelY(buBy[lvix]));
        GfxLineTo(GfxConvertBarToPixelX(i-(buDx[lvix]-buCx[lvix])),GfxConvertValueToPixelY(buCy[lvix]));   
        GfxSelectFont("Tahoma",10,500);GfxSetBkMode(1);
        GfxSetTextColor(colorAqua);GfxTextOut("1",GfxConvertBarToPixelX(i-(buDx[lvix]-buBx[lvix]))+3,GfxConvertValueToPixelY(buBy[lvix]-1.6*abcdy_dn));
        GfxSetTextColor(colorAqua);GfxTextOut("2",GfxConvertBarToPixelX(i-(buDx[lvix]-buCx[lvix]))+3,GfxConvertValueToPixelY(buCy[lvix]+1.5*abcdy_up));
        GfxSetTextColor(colorAqua);GfxTextOut("3",GfxConvertBarToPixelX(i-(buDx[lvix]-buDx[lvix]))+3,GfxConvertValueToPixelY(buDy[lvix]-1.6*abcdy_dn));
        Plot(LineArray(buCx[lvix],buCy[lvix],buEx[lvix],buEy[lvix],0,True ),"",colorLime,styleDashed);
        Plot(buTrendline,"",colorLime,styleDots|styleNoLine,0,0,0,0);   
        PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBrightGreen,0,L,-15);
        //PlotShapes(IIf(Buy,shapeSmallCircle,shapeNone),colorWhite,0,BuyPrice,0);
        if(dispbuRetraceValues)
        {       
            GfxSelectFont("Tahoma",8,650); GfxSetBkMode(2);GfxSetOverlayMode(1);GfxSetBkColor(colorDarkGreen);GfxSetTextColor(colorWhite);
            GfxTextOut(""+Prec(buRetrace[lvix],2),GfxConvertBarToPixelX(i-(buDx[lvix]-(buAx[lvix]+buCx[lvix])/2)),GfxConvertValueToPixelY((buAy[lvix]+buCy[lvix])/2));
        }           
    }
}

Wednesday, 20 May 2020

Candlestick Exploration for Amibroker (AFL)


This Best AFL for Exploring the patterns of the stock.

Candlestick Exploration for Amibroker (AFL)



Most Powerful Candlestick Patterns You Must Know - Trading Tuitions



MAXH5=HHV(High,5)==High;
MaxH5COLOR=IIf(MAXH5,colorBrightGreen,colorWhite);

MAXH5Y=HHV(High,5)==Ref(High,-1);
MAXH5YCOLOR=IIf(MAXH5Y,colorBrightGreen,colorWhite);

MINL5=LLV(Low,5)==Low;
MINL5COLOR=IIf(MinL5,colorBrightGreen,colorWhite);

MINL5Y=LLV(Low, 5)==Ref(Low,-1);
MINL5YCOLOR=IIf(MINL5Y,colorBrightGreen,colorWhite);

DOJI1=abs(Close-Open) <= (Close*.0025);
DOJI1COLOR=IIf(DOJI1,colorBrightGreen,colorWhite);

DOJI2=(abs(Open-Close)<=((High-Low)*0.1));
DOJI2COLOR=IIf(DOJI2,colorBrightGreen,colorWhite);

DOJI1Y=abs(Ref(Close,-1)-Ref(Open,-1)) <= (Ref(Close,-1)*.0025);
DOJI1YCOLOR=IIf(DOJI1Y,colorBrightGreen,colorWhite);

DOJI2Y=(abs(Ref(Open,-1)-Ref(Close,-1))<=((Ref(High,-1)-Ref(Low,-1))*0.1));
DOJI2YCOLOR=IIf(DOJI2Y,colorBrightGreen,colorWhite);

MRNSTAR=Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(Open,-1)<=Ref(Close,-2) AND Ref(Close,-1)<=Ref(Close,-2) AND Close>Ref(Close,-2) AND Close>=Open*1.01;
MRNSTARCOLOR=IIf(MRNSTAR,colorBrightGreen,colorWhite);

ABBABY=Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(High,-1)<Ref(Low,-2) AND Low>Ref(High,-1) AND Close>=Open*1.01;
ABBABYCOLOR=IIf(ABBABY,colorBrightGreen,colorWhite);

TRISTARBLSH=LLV(Low,3)==LLV(Low, 13) AND (HHV(High, 3)-LLV(Low, 3))<=(HHV(High, 3)*.01);
TRISTARBLSHCOLOR=IIf(TRISTARBLSH,colorBrightGreen,colorWhite);

TSTARSO=LLV(Low,8)==Ref(Low,-2) AND Ref(Close,-2)<Ref(Open,-2) AND Ref(Close,-2)>=(Ref(Low,-2)+((Ref(High,-2)-Ref(Low,-2))*.25)) AND Ref(Open,-1)>Ref(Close,-2) AND Ref(Low,-1)>Ref(Low,-2) AND Ref(Close,-1)>=(Ref(Low,-1)+((Ref(High,-1)-Ref(Low,-1))*.25)) AND Ref(Close,-1)<Ref(Open,-1) AND High<Ref(High,-1) AND Low>Ref(Low,-1) AND High-Low<=(High*.01);
TSTARSOCOLOR=IIf(TSTARSO,colorBrightGreen,colorWhite);

BLHARAMI=Ref(Close,-1)<=Ref(Open,-1)*.99 AND High<=Ref(Open,-1) AND Low>=Ref(Close,-1) AND Close>Open;
BLHARAMICOLOR=IIf(BLHARAMI,colorBrightGreen,colorWhite);

TINSDUP=Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(High,-1)<=Ref(Open,-2) AND Ref(Low,-1)>=Ref(Close,-2) AND Close>Ref(Open,-2);
TINSDUPCOLOR=IIf(TINSDUP,colorBrightGreen,colorWhite);

HARAMICRS=Ref(Close,-1)<=Ref(Open,-1)*.99 AND High<Ref(Open,-1) AND Low>Ref(Close,-1);
HARAMICRSCOLOR=IIf(HARAMICRS,colorBrightGreen,colorWhite);

HARAMIPG=Ref(Close,-1)<=Ref(Open,-1)*.99 AND High<=Ref(Open,-1) AND Low>=Ref(Close,-1) AND Close<Open;
HARAMIPGCOLOR=IIf(HARAMIPG,colorBrightGreen,colorWhite);

KICKBULL=Ref(Close,-1)<=Ref(Open,-1)*.99 AND Low>=Ref(High,-1) AND Close>=Open*1.01;
KICKBULLCOLOR=IIf(KICKBULL,colorBrightGreen,colorWhite);

HIPRCGAP=Ref(Close,-4)>=Ref(Open,-4)*1.01 AND HHV(Ref(High, -1),3)<=Ref(High,-4) AND LLV(Ref(Low, -1), 3) >=Ref(Low,-4) AND Close>Open*1.01 AND Low>=Ref(High,-4);
HIPRCGAPCOLOR=IIf(HIPRCGAP,colorBrightGreen,colorWhite);

SDBSDWTLN=HHV(High,2)==HHV(High,8) AND Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Low,-1)>Ref(High,-2) AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND Low>Ref(High,-2) AND Open<=Ref(Open,-1)*1.005 AND Close>=Open*1.01;
SDBSDWTLNCOLOR=IIf(SDBSDWTLN,colorBrightGreen,colorWhite);

UPSGAP3=Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Low,-1)>Ref(High,-2) AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND Open<Ref(Close,-1) AND Open>Ref(High,-2) AND Close<Ref(Close,-2);
UPSGAP3COLOR=IIf(UPSGAP3,colorBrightGreen,colorWhite);

TASUKIGAPBLSH=Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Low,-1)>Ref(High,-2) AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND Close<Open AND Close<Ref(Close,-1) AND Low>Ref(High,-2);
TASUKIGAPBLSHCOLOR=IIf(TASUKIGAPBLSH,colorBrightGreen,colorWhite);

HAMMER=Open>=(High-((High-Low)*.25)) AND Close>=(High-((High-Low)*.25));
HAMMERCOLOR=IIf(HAMMER,colorBrightGreen,colorWhite);

INVHAMMER=Open<=(Low+((High-Low)*.25)) AND Close<=(Low+((High-Low)*.25));
INVHAMMERCOLOR=IIf(INVHAMMER,colorBrightGreen,colorWhite);

TRIVBOT=Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(Open,-1)>Ref(Close,-2) AND Ref(Close,-1)>Ref(Close,-2) AND Close>Open AND Close<Ref(Open,-2) AND Open>Ref(Close,-2) AND Ref(Open,-1)>=(Ref(High,-1)-((Ref(High,-1)-Ref(Low,-1))*.25)) AND Ref(Close,-1)>=(Ref(High,-1)-((Ref(High,-1)-Ref(Low,-1))*.25));
TRIVBOTCOLOR=IIf(TRIVBOT,colorBrightGreen,colorWhite);

CONBABYSW=Ref(Close,-3)<=Ref(Open,-3)*.99 AND Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(Open,-1)<Ref(Close,-2) AND Ref(High,-1)>Ref(Close,-2) AND Open>Ref(Close,-2) AND Close<=Ref(Close,-1) AND LLV(Low,2)==LLV(Low,8);
CONBABYSWCOLOR=IIf(CONBABYSW,colorBrightGreen,colorWhite);

LLDOJIBLSH=Open<Ref(Low,-1) AND High>=Low*1.01;
LLDOJIBLSHCOLOR=IIf(LLDOJIBLSH,colorBrightGreen,colorWhite);

MATCHLOW=LLV(Low,8)==LLV(Low,2) AND Ref(Close,-1)<=Ref(Open,-1)*.99 AND abs(Close-Ref(Close,-1))<=Close*.0025 AND Open>Ref(Close,-1) AND Open<=(High-((High-Low)*.5));
MATCHLOWCOLOR=IIf(MATCHLOW,colorBrightGreen,colorWhite);

BELTHOLD=Open<=Ref(Low,-1)*.99 AND Close>Ref(Low,-1);
BELTHOLDCOLOR=IIf(BELTHOLD,colorBrightGreen,colorWhite);

BULLENG=Open<Ref(Low,-1) AND Close>Ref(High,-1) AND Close>=Open*1.01;
BULLENGCOLOR=IIf(BULLENG,colorBrightGreen,colorWhite);

TOUTSUP=Ref(Open,-1)<Ref(Low,-2) AND Ref(Close,-1)>Ref(High,-2) AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND Close>Ref(High,-1) AND Close>Open;
TOUTSUPCOLOR=IIf(TOUTSUP,colorBrightGreen,colorWhite);

STICKSAND=LLV(Low, 8)==LLV(Low, 3) AND Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND Ref(Close,-1)>=Ref(High,-2) AND Open>=Ref(High,-1) AND abs(Close-Ref(Close,-2))<=Close*.0025;
STICKSANDCOLOR=IIf(STICKSAND,colorBrightGreen,colorWhite);

BREAKAWAY=Ref(Close,-4)<Ref(Open,-4) AND HHV(Ref(High,-1), 3) < Ref(Low,-4) AND Open < HHV(Ref(High,-1), 3) AND Close>Ref(Low,-4);
BREAKAWAYCOLOR=IIf(BREAKAWAY,colorBrightGreen,colorWhite);

MEETLNS=Ref(Close,-1)<=Ref(Open,-1)*.99 AND abs(Close-Ref(Close,-1))<=Close*.0025 AND Close>=Open*1.01;
MEETLNSCOLOR=IIf(MEETLNS,colorBrightGreen,colorWhite);

PRCLINE=Ref(Close,-1)<=Ref(Open,-1)*.99 AND Open<Ref(Low,-1) AND Close>=(Close+((Open-Close)*.5));
PRCLINECOLOR=IIf(PRCLINE,colorBrightGreen,colorWhite);

TWHITESOLD=LLV(Low,8)==Ref(Low,-2) AND Ref(Open,-1)<Ref(Close,-2) AND Open<Ref(Close,-1) AND Ref(Close,-1)>Ref(Close,-2) AND Close>Ref(Close,-1) AND Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND Close>=Open*1.01;
TWHITESOLDCOLOR=IIf(TWHITESOLD,colorBrightGreen,colorWhite);

TLINESTRK=Ref(Open,-2)<Ref(Close,-3) AND Ref(Open,-1)<Ref(Close,-2) AND Ref(Close,-2)>Ref(Close,-3) AND Ref(Close,-1)>Ref(Close,-2) AND Ref(Close,-3)>=Ref(Open,-3)*1.01 AND Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND Open>Ref(Close,-1) AND Close< LLV( Ref(Open,-1), 3);
TLINESTRKCOLOR=IIf(TLINESTRK,colorBrightGreen,colorWhite);

SEPLINES=Ref(Close,-1)<=Ref(Open,-1)*.99 AND abs(Open-Ref(Open,-1))<=Open*.0025 AND Close>=Open*1.01;
SEPLINESCOLOR=IIf(SEPLINES,colorBrightGreen,colorWhite);

RISTHREE=Ref(Close,-4)>Ref(Open,-4) AND Ref(High,-3)>Ref(High,-4) AND Ref(High,-1)<Ref(High,-3) AND Ref(Low,-1)<Ref(Low,-3) AND Ref(Close,-3)<Ref(Open,-3) AND LLV(Ref(Low,-1),3)>Ref(Low,-4) AND Close>=Open*1.01 AND Close>HHV(Ref(H,-1),3);
RISTHREECOLOR=IIf(RISTHREE,colorBrightGreen,colorWhite);

MATHOLD=Ref(Close,-4)>=Ref(Open,-4)*1.01 AND Ref(Low,-3)>Ref(High,-4) AND Ref(High,-1)<Ref(High,-3) AND Ref(Low,-1)<Ref(Low,-3) AND Ref(Close,-3)<Ref(Open,-3) AND LLV(Ref(L,-1),3) > Ref(Low,-4) AND Open<Ref(Open,-1) AND Close>HHV(Ref(H,-1),3) AND Close>=Open*1.01;
MATHOLDCOLOR=IIf(MATHOLD,colorBrightGreen,colorWhite);

EVNSTAR=Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Open,-1)>=Ref(Close,-2) AND Ref(Close,-1)>=Ref(Close,-2) AND Open<=Ref(Close,-1) AND Close<=Open*.99;
EVNSTARCOLOR=IIf(EVNSTAR,colorBrightGreen,colorWhite);

ABBABYBRSH=Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Low,-1)>Ref(High,-2) AND High<Ref(Low,-1) AND Close<=Open*.99;
ABBABYBRSHCOLOR=IIf(ABBABYBRSH,colorBrightGreen,colorWhite);

TWOCROWS=Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Open,-1)>=Ref(Close,-2) AND Ref(Close,-1)>=Ref(Close,-2) AND Open>Ref(Low,-1) AND Open<Ref(High,-1) AND Close<=Open*.99;
TWOCROWSCOLOR=IIf(TWOCROWS,colorBrightGreen,colorWhite);

UPSGAPTWOCROWS=Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Open,-1)>=Ref(Close,-2) AND Ref(Close,-1)>=Ref(Close,-2) AND Open>Ref(High,-1) AND Close<Ref(Low,-1);
UPSGAPTWOCROWSCOLOR=IIf(UPSGAPTWOCROWS,colorBrightGreen,colorWhite);

TSTARBRSH=HHV(High, 3)==HHV(High, 13) AND (HHV(High, 3)-LLV(Low, 3))<=( HHV(High, 3)*.01);
TSTARBRSHCOLOR=IIf(TSTARBRSH,colorBrightGreen,colorWhite);

SHOOTSTAR=Low>Ref(High,-1) AND Open<=(Low+((High-Low)*.25)) AND Close<=(Low+((High-Low)*.25));
SHOOTSTARCOLOR=IIf(SHOOTSTAR,colorBrightGreen,colorWhite);

HANGMAN=Open>Ref(High,-1) AND Open>=(High-((High-Low)*.25)) AND Close>=(High-((High-Low)*.25));
HANGMANCOLOR=IIf(HANGMAN,colorBrightGreen,colorWhite);

SBSWHTLINESBRSH=LLV(Low, 8)==LLV(Low, 2) AND Ref(High,-1)<Ref(Low,-2) AND High<Ref(Low,-2) AND Ref(Close,-2)<=Ref(Open,-2)*.99 AND Open<=Ref(Open,-1)*1.005 AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND Close>=Open*1.01;
SBSWHTLINESBRSHCOLOR=IIf(SBSWHTLINESBRSH,colorBrightGreen,colorWhite);

LOWPRCGAP=Ref(Close,-4)<Ref(Open,-4)*.99 AND HHV(Ref(High,-1),3)<=(LLV(Ref(Low, -1),3)*1.01) AND High<LLV(Ref(Low,-1),3) AND Close<Open;
LOWPRCGAPCOLOR=IIf(LOWPRCGAP,colorBrightGreen,colorWhite);

DOWNGAP3=Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(High,-1)<Ref(Low,-2) AND Ref(Close,-1)<=Ref(Open,-1)*.99 AND Open<Ref(Open,-1) AND Close>Ref(Close,-2);
DOWNGAP3COLOR=IIf(DOWNGAP3,colorBrightGreen,colorWhite);

TASUKIGAPBRSH=Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(High,-1)<Ref(Low,-2) AND Ref(Close,-1)<=Ref(Open,-1)*.99 AND Open<Ref(High,-1) AND Close>Ref(High,-1) AND High<Ref(Low,-2);
TASUKIGAPBRSHCOLOR=IIf(TASUKIGAPBRSH,colorBrightGreen,colorWhite);

HARAMIBRSH=Ref(Close,-1)>=Ref(Open,-1)*1.01 AND High<Ref(Close,-1) AND Low>Ref(Open,-1);
HARAMIBRSHCOLOR=IIf(HARAMIBRSH,colorBrightGreen,colorWhite);

TINSIDEDOWN=Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(High,-1)<Ref(Close,-2) AND Ref(Low,-1)>Ref(Open,-2) AND Close<Ref(Open,-2) AND Open>Ref(Open,-2);
TINSIDEDOWNCOLOR=IIf(TINSIDEDOWN,colorBrightGreen,colorWhite);

HARAMICROSS=Ref(Close,-1)>=Ref(Open,-1)*1.01 AND High<Ref(Close,-1) AND Low>Ref(Open,-1);
HARAMICROSSCOLOR=IIf(HARAMICROSS,colorBrightGreen,colorWhite);

BRSHENGULF=Open>Ref(High,-1) AND Close<Ref(Low,-1);
BRSHENGULFCOLOR=IIf(BRSHENGULF,colorBrightGreen,colorWhite);

TINSIDDOWN=Ref(Open,-1)>Ref(High,-2) AND Ref(Close,-1)<Ref(Low,-2) AND Close<Open AND Close<Ref(Close,-1);
TINSIDDOWNCOLOR=IIf(TINSIDDOWN,colorBrightGreen,colorWhite);

DARKCLOUD=Ref(Open,-1)>=Ref(Close,-1)*1.01 AND Open>Ref(Close,-1) AND Close<=(Ref(Close,-1)-((Ref(Close,-1)-Ref(Open,-1))*.5));
DARKCLOUDCOLOR=IIf(DARKCLOUD,colorBrightGreen,colorWhite);

BELTHOLD=Open>=Ref(High,-1)*1.01 AND Close<Ref(High,-1);
BELTHOLDCOLOR=IIf(BELTHOLD,colorBrightGreen,colorWhite);

MTGLINES=Ref(Close,-1)>Ref(Open,-1) AND Open>=Ref(Close,-1)*1.01 AND abs(Close-Ref(Close,-1))<=Close*.0025;
MTGLINESCOLOR=IIf(MTGLINES,colorBrightGreen,colorWhite);

LLDOJIBRSH=Open>Ref(High,-1) AND High>=Low*1.01;
LLDOJIBRSHCOLOR=IIf(LLDOJIBRSH,colorBrightGreen,colorWhite);

ADVBLOCK=Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(High,-1)>Ref(High,-2) AND Ref(Close,-1)>Ref(Open,-1) AND Close>Open AND High>Ref(High,-1) AND (Ref(Close,-1)-Ref(Open,-1))<(Ref(Close,-2)-Ref(Open,-2)) AND (Close-Open)<(Ref(Close,-1)-Ref(Open,-1));
ADVBLOCKCOLOR=IIf(ADVBLOCK,colorBrightGreen,colorWhite);

DELIB=Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(High,-1)>Ref(High,-2) AND Ref(Close,-1)>Ref(Open,-1)*1.01 AND Close>Open AND High>Ref(High,-1) AND (Close-Open)<(Ref(Close,-1)-Ref(Open,-1));
DELIBCOLOR=IIf(DELIB,colorBrightGreen,colorWhite);

TBLKCROWS=HHV(High,8)==Ref(High,-2) AND Ref(Open,-1)>Ref(Close,-2) AND Open>Ref(Close,-1) AND Ref(Close,-1)<Ref(Close,-2) AND Close<Ref(Close,-1) AND Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(Close,-1)<=Ref(Open,-1)*.99 AND Close<=Open*.99;
TBLKCROWSCOLOR=IIf(TBLKCROWS,colorBrightGreen,colorWhite);

TLNSTRIKE=HHV(High,8)==Ref(High,-3) AND Ref(Open,-2)>Ref(Close,-3) AND Ref(Open,-1)>Ref(Close,-2) AND Ref(Close,-2)<Ref(Close,-3) AND Ref(Close,-1)<Ref(Close,-2) AND Ref(Close,-3)<=Ref(Open,-3)*.99 AND Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(Close,-1)<=Ref(Open,-1)*.99 AND Open<Ref(Low,-1) AND Close>HHV(Ref(H,-1),3);
TLNSTRIKECOLOR=IIf(TLNSTRIKE,colorBrightGreen,colorWhite);

ONNECK=Ref(Close,-1)<=Ref(Open,-1)*.99 AND Open<Ref(Low,-1) AND Close>Open AND Close<Ref(Close,-1);
ONNECKCOLOR=IIf(ONNECK,colorBrightGreen,colorWhite);

INNECK=Ref(Close,-1)<=Ref(Open,-1)*.99 AND Open<Ref(Low,-1) AND Close>Open AND abs(Close-Ref(Close,-1))<=(Close*.0025);
INNECKCOLOR=IIf(INNECK,colorBrightGreen,colorWhite);

SEPLINES=Ref(Close,-1)>=Ref(Open,-1)*1.01 AND abs(Open-Ref(Open,-1))<=Open*.0025 AND Close<Open*.99;
SEPLINESCOLOR=IIf(SEPLINES,colorBrightGreen,colorWhite);

FALL3=Ref(Close,-4)<Ref(Open,-4) AND Ref(High,-3)<Ref(High,-4) AND Ref(High,-1)>Ref(High,-3) AND Ref(Low,-1)>Ref(Low,-3) AND HHV(Ref(H,-1),3) <= Ref(High,-4) AND Open>Ref(Low,-1) AND Close<LLV(Ref(Low,-1),3);
FALL3COLOR=IIf(FALL3,colorBrightGreen,colorWhite);

Filter = 1;

AddColumn(MAXH5,"Maximum High Today",1,colorBlack,MaxH5color);
AddColumn(MAXH5Y,"Maximum High Yesterday ",1,colorBlack,MaxH5Ycolor);
AddColumn(MINL5,"Minimum Low Today",1,colorBlack,MINL5Ycolor);
AddColumn(MINL5Y,"Minimum Low Yesterday",1,colorBlack,MINL5Ycolor);
AddColumn(DOJI1,"Doji 1",1,colorBlack,DOJI1color);
AddColumn(DOJI2,"Doji 2",1,colorBlack,DOJI2color);
AddColumn(DOJI1Y,"Doji Yesterday 1",1,colorBlack,DOJI1Ycolor);
AddColumn(DOJI2Y,"Doji Yesterday 2",1,colorBlack,DOJI2Ycolor);
AddColumn(MRNSTAR,"Morning Star ",1,colorBlack,MRNSTARcolor);
AddColumn(ABBABY,"Abandoned Baby",1,colorBlack,ABBABYcolor);
AddColumn(TSTARSO,"Tri Star",1,colorBlack,TSTARSOcolor);
AddColumn(TRISTARBLSH,"Three Stars in the South",1,colorBlack,TRISTARBLSHcolor);
AddColumn(BLHARAMI,"Bullish Harami",1,colorBlack,BLHARAMIcolor);
AddColumn(TINSDUP,"3 Inside Up Confirmation",1,colorBlack,TINSDUPcolor);
AddColumn(HARAMICRS,"Harami Cross",1,colorBlack,HARAMICRScolor);
AddColumn(HARAMIPG,"Homing Pigeon",1,colorBlack,HARAMIPGcolor);
AddColumn(KICKBULL,"Kicking Bullish",1,colorBlack,KICKBULLcolor);
AddColumn(HIPRCGAP,"High Price Gapping",1,colorBlack,HIPRCGAPcolor);
AddColumn(SDBSDWTLN,"Side by Side White Lines",1,colorBlack,SDBSDWTLNcolor);
AddColumn(UPSGAP3,"Tasuki Gap",1,colorBlack,UPSGAP3color);
AddColumn(HAMMER,"Hammer",1,colorBlack,HAMMERcolor);
AddColumn(INVHAMMER,"Inverted Hammer",1,colorBlack,INVHAMMERcolor);
AddColumn(TRIVBOT,"Three River Bottom",1,colorBlack,TRIVBOTcolor);
AddColumn(CONBABYSW,"Concealing Baby Swallow",1,colorBlack,CONBABYSWcolor);
AddColumn(LLDOJIBLSH,"Long Legged Doji",1,colorBlack,LLDOJIBLSHcolor);
AddColumn(MATCHLOW,"Matching Low",1,colorBlack,MATCHLOWcolor);
AddColumn(BELTHOLD,"Belt Hold",1,colorBlack,BELTHOLDcolor);
AddColumn(BULLENG,"Bullish Engulfing",1,colorBlack,BULLENGcolor);
AddColumn(TOUTSUP,"Three Outside Up",1,colorBlack,TOUTSUPcolor);
AddColumn(STICKSAND,"Stick Sandwich",1,colorBlack,STICKSANDcolor);
AddColumn(MEETLNS,"Meeting Lines",1,colorBlack,MEETLNScolor);
AddColumn(BREAKAWAY,"Breakaway",1,colorBlack,BREAKAWAYcolor);
AddColumn(PRCLINE,"Piercing Line",1,colorBlack,PRCLINEcolor);
AddColumn(TWHITESOLD,"Three White Soldiers",1,colorBlack,TWHITESOLDcolor);
AddColumn(TLINESTRK,"Three Line Strike",1,colorBlack,TLINESTRKcolor);
AddColumn(SEPLINES,"Seperating Lines",1,colorBlack,SEPLINEScolor);
AddColumn(RISTHREE,"Rising Three",1,colorBlack,RISTHREEcolor);
AddColumn(MATHOLD,"Mat Hold",1,colorBlack,MATHOLDcolor);
AddColumn(EVNSTAR,"Evening Star",1,colorBlack,EVNSTARcolor);
AddColumn(ABBABYBRSH,"Abandoned Baby bearish",1,colorBlack,ABBABYBRSHcolor);
AddColumn(TWOCROWS,"Two Crows",1,colorBlack,TWOCROWScolor);
AddColumn(UPSGAPTWOCROWS,"Upside Gap Two Crows",1,colorBlack,UPSGAPTWOCROWScolor);
AddColumn(SHOOTSTAR,"Shooting Star",1,colorBlack,SHOOTSTARcolor);
AddColumn(TSTARBRSH,"Tri-Star bearish",1,colorBlack,TSTARBRSHcolor);
AddColumn(HANGMAN,"Hanging Man",1,colorBlack,HANGMANcolor);
AddColumn(SBSWHTLINESBRSH,"Side by Side White Lines bearish",1,colorBlack,SBSWHTLINESBRSHcolor);
AddColumn(LOWPRCGAP,"Low Price Gapping",1,colorBlack,LOWPRCGAPcolor);
AddColumn(DOWNGAP3,"Downside Gap Three",1,colorBlack,DOWNGAP3color);
AddColumn(TASUKIGAPBRSH,"Tasuki Gap",1,colorBlack,TASUKIGAPBRSHcolor);
AddColumn(HARAMIBRSH,"Harami bearish",1,colorBlack,HARAMIBRSHcolor);
AddColumn(TINSIDEDOWN,"3 Inside Down Confirmation",1,colorBlack,TINSIDEDOWNcolor);
AddColumn(HARAMICROSS,"Harami Cross",1,colorBlack,HARAMICROSScolor);
AddColumn(BRSHENGULF,"Engulfing bearish",1,colorBlack,BRSHENGULFcolor);
AddColumn(TINSIDDOWN,"Three Inside Down ",1,colorBlack,TINSIDDOWNcolor);
AddColumn(DARKCLOUD,"Dark Cloud Cover ",1,colorBlack,DARKCLOUDcolor);
AddColumn(BELTHOLD,"Belt Hold",1,colorBlack,BELTHOLDcolor);
AddColumn(MTGLINES,"Meeting Lines",1,colorBlack,MTGLINEScolor);
AddColumn(LLDOJIBRSH,"Long Legged Doji",1,colorBlack,LLDOJIBRSHcolor);
AddColumn(ADVBLOCK,"Advance Block",1,colorBlack,ADVBLOCKcolor);
AddColumn(DELIB,"Deliberation",1,colorBlack,DELIBcolor);
AddColumn(TBLKCROWS,"Three Black Crows",1,colorBlack,TBLKCROWScolor);
AddColumn(TLNSTRIKE,"Three Line Strike",1,colorBlack,TLNSTRIKEcolor);
AddColumn(ONNECK,"On Neck",1,colorBlack,ONNECKcolor);
AddColumn(INNECK,"In Neck",1,colorBlack,INNECKcolor);
AddColumn(SEPLINES,"Seperating Lines",1,colorBlack,SEPLINEScolor);
AddColumn(FALL3,"Falling Three",1,colorBlack,FALL3color);

What's new in the latest version?

What's new in the latest version?

Highlights of version 6.30
Version 6.30 brings lots of new functionality especially with regards to the formula language and performance . There are hundreds of new features and changes to existing functionality as compared to version 6.20, listed in detail in "Release Notes" document in AmiBroker directory. Below is just a short list of few of them:
  • HIGHLIGHT: User-definable on-chart GUI controls
  • 18 new AFL functions were added to allow creation of user-definable on-chart graphical user interfaces.

  • New features in AmiBroker Formula Language
  • Huge performance improvements in 64-bit version with migration to new VC++2017 compiler

    Why do we migrate to new compiler with 64-bit version?
    • New compiler supports new CPU instructions (SSE3/AVX) that we can use to offer better performance
    • According to our tests new compiler support produces faster code by itself (better optimizations, auto-vectorization, etc)
    • New compiler is better with error checking (less bugs to slip through)
    • We don't need to care about compatibility with pre-Vista systems in 64-bits version and all 64-bit capable CPUs are "modern" enough.
Why do we stay with old compiler in 32-bit version?
  • New compiler does not produce code compatible with older operating systems (XP or earlier). Old compiler offers 100% compatibility with all Windows versions
  • New compiler requires modern CPUs
Exact performance improvement is function dependent and hardware dependent. Many functions are faster by 30-50% but in some cases such as Min()/Max() functions as large as 8x speed up can be observed in 64-bit version.
  • Other key improvements
    • Auto-optimization framework
    • HTML5 compatibility in Web Research window
    • comment folding in the AFL editor
    • clickable links in Analysis result list

Sunday, 17 May 2020

Swing-Trading-system











swing-Trading-system

_SECTION_BEGIN("graph");

SetChartOptions(0,chartShowArrows|chartShowDates);

gxs=Param("GRAPH spaceing",10,5,50,5);

GraphXSpace = gxs;

strWeekday = StrMid("SunMonTueWedThuFriSat", SelectedValue(DayOfWeek())*3,3);

_SECTION_END();

_SECTION_BEGIN("NMA ");

k = Optimize("K",Param("K",1.75,1,5,0.25),1,5,0.25);

Per= Optimize("atr",Param("atr",10,3,30,1),3,30,1);

j=(O+H+L+C)/4;

nm= (H-L);

rfsctor = WMA(nm, PER);

revers = K * 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];

}

}

}

}


Plot(NW, "", IIf(Trend == 1, 6, 4), 4);


//---------------trading -------------


Buy=Cover=Cross(j,nw);

Sell=Short=Cross(nw,j);

Buy=ExRem(Buy,Sell);

Sell=ExRem(Sell,Buy);

Short=ExRem(Short,Cover);

Cover=ExRem(Cover,Short);

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorSkyblue, 0,Low,-15);

PlotShapes(IIf(Sell, shapeHollowDownArrow, shapeNone),colorLightYellow, 0,High,-15);

PlotShapes(IIf(Cover, shapeHollowCircle, shapeNone),colorTan, 0,Close,0);

PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorGold, 0,High,-25);

//-----------end--------------

Long=Flip(Buy,Sell OR Cover);

Shrt=Flip(Sell,Buy OR Cover);

NOTrade= NOT (Long OR shrt);

Edc=(

WriteIf (Buy AND Ref(shrt,-1), " GO LONG / Reverse Signal at "+C+" ","")+

WriteIf (Buy AND Ref(NOTrade,-1), " GO LONG at "+C+" ","")+

WriteIf (Sell AND Ref(NOTrade,-1), " GO Short at "+C+" ","")+

WriteIf (Sell AND Ref(Long,-1), " EXIT LONG / Reverse Signal at "+C+" ",""));

_SECTION_END();

grid_day = IIf(Day()!=Ref(Day(),-1),1,0);

Plot(grid_day,"",colorDarkGrey,styleHistogram|styleDashed|styleNoLabel|styleOwnScale);

///--------------------------------------------------------------------------------------------------


UpCandle = ParamColor("Up Color", colorBrightGreen );

DownCandle = ParamColor("Down Color", colorDarkRed );

Consolidation = ParamColor("Consolidation", colorBlack );

BG2a=HHV(LLV(L,4)+ATR(4),8);

BR2a=LLV(HHV(H,4)-ATR(4),8);

Candlecolor = IIf(Close>BG2a ,UpCandle,IIf(Close < BR2a,DownCandle,Consolidation));

SetBarFillColor( IIf(O <C, colorSeaGreen,colorOrange) );

Plot( Close, "Price", CandleColor, styleCandle );

TimeFrameSet( 2*Interval() );

BG2=HHV(LLV(L,4)+ATR(4),8);

BR2=LLV(HHV(H,4)-ATR(4),8);

C1=C;

TimeFrameRestore();

M5 = TimeFrameExpand(BG2,2*Interval() );

MM5=TimeFrameExpand( BR2,2*Interval() );

cM5=TimeFrameExpand( C1, 2*Interval() );

TimeFrameSet( 4*Interval() );

BG2=HHV(LLV(L,4)+ATR(4),8);

BR2=LLV(HHV(H,4)-ATR(4),8);

C1=C;

TimeFrameRestore();

M15 = TimeFrameExpand(BG2,4*Interval() );

MM15=TimeFrameExpand(BR2,4*Interval() );

cM15=TimeFrameExpand( C1,4*Interval() );

TimeFrameSet( 6*Interval() );

BG2=HHV(LLV(L,4)+ATR(4),8);

BR2=LLV(HHV(H,4)-ATR(4),8);

C1=C;

TimeFrameRestore();

M30 = TimeFrameExpand(BG2,6*Interval() );

MM30=TimeFrameExpand(BR2,6*Interval() );

cM30=TimeFrameExpand( C1,6*Interval() );

TimeFrameSet( 8*Interval() );

BG2=HHV(LLV(L,4)+ATR(4),8);

BR2=LLV(HHV(H,4)-ATR(4),8);

C1=C;

TimeFrameRestore();

H1 = TimeFrameExpand(BG2 ,8*Interval() );

HH1=TimeFrameExpand( BR2,8*Interval() );

Ch1=TimeFrameExpand( C1,8*Interval() );

TimeFrameSet( 16*Interval() );

BG2=HHV(LLV(L,4)+ATR(4),8);

BR2=LLV(HHV(H,4)-ATR(4),8);

C1=C;

TimeFrameRestore();

H4 = TimeFrameExpand( BG2,16*Interval() );

HH4=TimeFrameExpand( BR2,16*Interval() );

cH4 = TimeFrameExpand( C1,16*Interval() );

Com=("\n "+Name()+ " - Trend in ")+"\n "+

EncodeColor(colorLightGrey)+(""+Interval(2)+":")+

WriteIf(Close>BG2a,EncodeColor(colorLime)+" UP",WriteIf(Close<BR2a,EncodeColor(colorRed)+" DN",EncodeColor(colorGrey50)+" ~~"))+

EncodeColor(colorLightGrey)+(" "+2*Interval()/60+"m:")+

WriteIf(Cm5>M5,EncodeColor(colorLime)+" UP",WriteIf(Cm5<MM5,EncodeColor(colorRed)+" DN",EncodeColor(colorGrey50)+" ~~"))+

EncodeColor(colorLightGrey)+(" "+4*Interval()/60+"m:")+

WriteIf(Cm15>M15,EncodeColor(colorLime)+" UP",WriteIf(Cm15<MM15,EncodeColor(colorRed)+" DN",EncodeColor(colorGrey50)+" ~~"))+

EncodeColor(colorLightGrey)+(" "+6*Interval()/60+"m:")+

WriteIf(Cm30>M30,EncodeColor(colorLime)+" UP",WriteIf(Cm30<MM30,EncodeColor(colorRed)+" DN",EncodeColor(colorGrey50)+" ~~"))+

EncodeColor(colorLightGrey)+(" "+8*Interval()/60+"m:")+

WriteIf(CH1>H1,EncodeColor(colorLime)+" UP",WriteIf(CH1<HH1,EncodeColor(colorRed)+" DN",EncodeColor(colorGrey50)+" ~~"))+

EncodeColor(colorLightGrey)+(" "+16*Interval()/60+"m: ")+

WriteIf(Ch4>H4,EncodeColor(colorLime)+" UP",WriteIf(Ch4<HH4,EncodeColor(colorRed)+" DN",EncodeColor(colorGrey50)+" ~~" ));

//---------------------------------------------------------------------------------------

Vr=ParamList("Index",List = "^NSEI,^NSEBANK,NIFTY_F1,RELIANCE.NS,SBIN.NS,EURUSD,XAUUSD,GOLD",0);

SetForeign(Vr);

HaC =(O+H+L+C)/4;

HaO = AMA( Ref( HaC, -1 ), 0.5 );

HaH = Max( H, Max( HaC, HaO) );

HaL = Min( L, Min( HaC, HaO) );

HBG=HHV(LLV(HaL,4)+ATR(4),8);

HBR=LLV(HHV(HaH ,4)-ATR(4),8);

co = IIf(Hac>HBG ,colorAqua,IIf(Hac < HBR,colorCustom12,colorGrey50));

Plot(4, "", Co,styleArea+styleOwnScale | styleNoLabel, -1, 100);

//PlotOHLC(HaO,HaH,HaL,HaC, "", Co,styleCandle|styleOwnScale );

//=====================================================================================

TimeFrameSet( 2*Interval() );

BG2H=HHV(LLV(HaL,4)+ATR(4),8);

BR2H=LLV(HHV(HaH,4)-ATR(4),8);

C1H=HaC;

TimeFrameRestore();

M5H = TimeFrameExpand(BG2H,2*Interval() );

MM5H=TimeFrameExpand( BR2H,2*Interval() );

cM5H=TimeFrameExpand( C1H, 2*Interval() );

TimeFrameSet( 4*Interval() );

BG2H=HHV(LLV(HaL,4)+ATR(4),8);

BR2H=LLV(HHV(HaH,4)-ATR(4),8);

C1H=HaC;

TimeFrameRestore();

M15H = TimeFrameExpand(BG2H,4*Interval() );

MM15H=TimeFrameExpand(BR2H,4*Interval() );

cM15H=TimeFrameExpand( C1H,4*Interval() );

TimeFrameSet( 6*Interval() );

BG2H=HHV(LLV(HaL,4)+ATR(4),8);

BR2H=LLV(HHV(HaH,4)-ATR(4),8);

C1H=HaC;

TimeFrameRestore();

M30H = TimeFrameExpand(BG2H,6*Interval() );

MM30H=TimeFrameExpand(BR2H,6*Interval() );

cM30H=TimeFrameExpand( C1H,6*Interval() );

TimeFrameSet( 8*Interval() );

BG2H=HHV(LLV(HaL,4)+ATR(4),8);

BR2H=LLV(HHV(HaH,4)-ATR(4),8);

C1H=HaC;

TimeFrameRestore();

H1H = TimeFrameExpand(BG2H ,8*Interval() );

HH1H=TimeFrameExpand( BR2H,8*Interval() );

Ch1H=TimeFrameExpand( C1H,8*Interval() );

TimeFrameSet( 16*Interval() );

BG2H=HHV(LLV(HaL,4)+ATR(4),8);

BR2H=LLV(HHV(HaH,4)-ATR(4),8);

C1H=HaC;

TimeFrameRestore();

H4H = TimeFrameExpand( BG2H,16*Interval() );

HH4H=TimeFrameExpand( BR2H,16*Interval() );

cH4H = TimeFrameExpand( C1H,16*Interval() );

RestorePriceArrays();

Comm2=("\n "+VR+ " - Phase in ")+"\n "+

EncodeColor(colorLightYellow)+(""+Interval(2)+":")+

WriteIf(Hac>HBG,EncodeColor(colorLime)+" UP",WriteIf(Hac < HBR,EncodeColor(colorRed)+" DN",EncodeColor(colorGrey50)+" ~~"))+

EncodeColor(colorLightYellow)+(" "+2*Interval()/60+"m:")+

WriteIf(cM5H>M5H,EncodeColor(colorLime)+" UP",WriteIf(cM5H<MM5H,EncodeColor(colorRed)+" DN",EncodeColor(colorGrey50)+" ~~"))+

EncodeColor(colorLightYellow)+(" "+4*Interval()/60+"m:")+

WriteIf(cM15H>M15H,EncodeColor(colorLime)+" UP",WriteIf(cM15H<MM15H,EncodeColor(colorRed)+" DN",EncodeColor(colorGrey50)+" ~~"))+

EncodeColor(colorLightYellow)+(" "+6*Interval()/60+"m:")+

WriteIf(cM30H>M30H,EncodeColor(colorLime)+" UP",WriteIf(cM30H<MM30H,EncodeColor(colorRed)+" DN",EncodeColor(colorGrey50)+" ~~"))+

EncodeColor(colorLightYellow)+(" "+8*Interval()/60+"m:")+

WriteIf(Ch1H>H1H,EncodeColor(colorLime)+" UP",WriteIf(Ch1H<HH1H,EncodeColor(colorRed)+" DN",EncodeColor(colorGrey50)+" ~~"))+

EncodeColor(colorLightYellow)+(" "+16*Interval()/60+"m: ")+

WriteIf(cH4H>H4H,EncodeColor(colorLime)+" UP",WriteIf(cH4H<HH4H,EncodeColor(colorRed)+" DN",EncodeColor(colorGrey50)+" ~~" ));

//============


BuyPrice=ValueWhen(Buy,C);

SellPrice=ValueWhen(Sell,C);

ShortPrice=ValueWhen(Short,C);

CoverPrice=ValueWhen(Cover,C);


_SECTION_BEGIN("Title");

if( Status("action") == actionIndicator )

(

Title = EncodeColor(colorWhite) + Name() + "-" + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +

" - " + Date() +" - "+ strWeekday +" - "+"\n" +EncodeColor(colorYellow) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+

"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+

EncodeColor(colorTan)+ Com+

EncodeColor(colorYellow)+ Comm2);

_SECTION_END();


_SECTION_BEGIN("Background text");

C11=ParamColor("up panel",colorDarkOliveGreen );

C12=ParamColor("dn panel",colorDarkGrey );

C13=Param("fonts",20,10,30,1 );

C14=Param("left-right",2.1,1.0,5.0,0.1 );

C15=Param("up-down",12,1,20,1 );

Miny = Status("axisminy");

Maxy = Status("axismaxy");

lvb = Status("lastvisiblebar");

fvb = Status("firstvisiblebar");

pxwidth = Status("pxwidth");

pxheight = Status("pxheight");

GfxSetBkMode( 0 );

GfxSetOverlayMode(1);

GfxGradientRect(0,0,pxwidth, pxheight, C11, C12 );

GfxSelectFont("Tahoma", Status("pxheight")/C13 );

GfxSetTextAlign( 6 );

GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );

GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );

GfxTextOut( "NMA", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );

GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );

GfxTextOut( " Karthik Marar", Status("pxwidth")/C14, Status("pxheight")/C15*4 );

GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);

GfxTextOut(""+Vr+"---cas67", Status("pxwidth")/1.08, Status("pxheight")/C15*10.8 );

GfxSelectFont("Ariel",9, 700, False, False, 0);

GfxSetTextColor(colorYellow);

GfxTextOut(""+edc+"", Status("pxwidth")/1.15, Status("pxheight")/C15*0.3 );

Thursday, 14 May 2020

How can I coding higher low value of MACD?



How can I coding higher low value of MACD?

 Untitled


Solution is

11


sig = Signal(); crss = Cross( MACD(), sig); prev_macd = ValueWhen(crss, MACD(), 2); Buy = crss AND MACD() > prev_macd; PlotShapes( Buy * shapeUpArrow, colorGreen, layer = 0, y = sig );

Monday, 4 May 2020

Pin Bar Candlestick Pattern Detector for Amibroker (AFL)



A pin bar pattern consists of one price bar, typically a candlestick price bar, which represents a sharp reversal and rejection of price. The pin bar reversal as it is sometimes called, is defined by a long tail, the tail is also referred to as a “shadow” or “wick”. The area between the open and close of the pin bar is called its “real body”, and pin bars generally have small real bodies in comparison to their long tails.

The tail of the pin bar shows the area of price that was rejected, and the implication is that price will continue to move opposite to the direction the tail points. Thus, a bearish pin bar signal is one that has a long upper tail, showing rejection of higher prices with the implication that price will fall in the near-term. A bullish pin bar signal has a long lower tail, showing rejection of lower prices with the implication that price will rise in the near-term.





_SECTION_BEGIN( "Pin Bar AFL" );

SetBarsRequired( 100000, 0 );

GraphXSpace = 15;

SetChartOptions( 0, chartShowArrows | chartShowDates );

SetChartBkColor( ParamColor( "bkcolor", ColorRGB( 0, 0, 0 ) ) );

GfxSetBkMode( 0 );

GfxSetOverlayMode( 1 );

SetBarFillColor( IIf( C > O, ParamColor( "Candle UP Color", colorGreen ), IIf( C <= O, ParamColor( "Candle Down Color", colorRed ), colorLightGrey ) ) );

Plot( C, "\nPrice", IIf( C > O, ParamColor( "Wick UP Color", colorDarkGreen ), IIf( C <= O, ParamColor( "Wick Down Color", colorDarkRed ), colorLightGrey ) ), 64, 0, 0, 0, 0 );

dec = ( Param( "Decimals", 2, 0, 7, 1 ) / 10 ) + 1;
Title = EncodeColor( 55 ) +  Title = Name() + "     " + EncodeColor( 32 ) + Date() +
                                     "      " + EncodeColor( 5 ) + "{{INTERVAL}}  " +
                                     EncodeColor( 55 ) + "     Open = " + EncodeColor( 52 ) + WriteVal( O, dec ) +
                                     EncodeColor( 55 ) + "     High = " + EncodeColor( 5 ) + WriteVal( H, dec ) +
                                     EncodeColor( 55 ) + "      Low = " + EncodeColor( 32 ) + WriteVal( L, dec ) +
                                     EncodeColor( 55 ) + "    Close = " + EncodeColor( 52 ) + WriteVal( C, dec ) +
                                     EncodeColor( 55 ) + "    Volume = " + EncodeColor( 52 ) + WriteVal( V, 1 );


MaxNoseBodySize = 0.33; // Max. Body / Candle length ratio of the Nose Bar
NoseBodyPosition = 0.4; // Body position in Nose Bar (e.g. top/bottom 40%)
LeftEyeOppositeDirection = True; // true = Direction of Left Eye Bar should be opposite to pattern (bearish bar for bullish Pinbar pattern and vice versa)
NoseSameDirection = False; // true = Direction of Nose Bar should be the same as of pattern (bullish bar for bullish Pinbar pattern and vice versa)
NoseBodyInsideLeftEyeBody = False; // true = Nose Body should be contained inside Left Eye Body
LeftEyeMinBodySize = 0.1; // Min. Body / Candle length ratio of the Left Eye Bar
NoseProtruding = 0.5; // Minmum protrusion of Nose Bar compared to Nose Bar length
NoseBodyToLeftEyeBody = 1; // Maximum relative size of the Nose Bar Body to Left Eye Bar Body
NoseLengthToLeftEyeLength = 0; // Minimum relative size of the Nose Bar Length to Left Eye Bar Length
LeftEyeDepth = 0.2; // Minimum relative depth of the Left Eye to its length; depth is difference with Nose's back

up = down = 0;
point = 0.1;
blpin = brpin = False;

for( i = 1; i < BarCount; i++ )
{

    NoseLength = High[i] - Low[i];

    if( NoseLength == 0 ) NoseLength = Point;

    LeftEyeLength = High[i - 1] - Low[i - 1];

    if( LeftEyeLength == 0 ) LeftEyeLength = Point;

    NoseBody = abs( Open[i] - Close[i] );

    if( NoseBody == 0 ) NoseBody = point;

    LeftEyeBody = abs( Open[i - 1] - Close[i - 1] );

    if( LeftEyeBody == 0 ) LeftEyeBody = point;

    // Bearish Pinbar
    if( High[i] - High[i - 1] >= NoseLength * NoseProtruding ) // Nose protrusion
    {
        if( NoseBody / NoseLength <= MaxNoseBodySize ) // Nose body to candle length ratio
        {
            if( 1 - ( High[i] - Max( Open[i], Close[i] ) ) / NoseLength < NoseBodyPosition ) // Nose body position in bottom part of the bar
            {
                if( ( !LeftEyeOppositeDirection ) || ( Close[i - 1] > Open[i - 1] ) ) // Left Eye bullish if required
                {
                    if( ( !NoseSameDirection ) || ( Close[i] < Open[i] ) ) // Nose bearish if required
                    {
                        if( LeftEyeBody / LeftEyeLength  >= LeftEyeMinBodySize ) // Left eye body to candle length ratio
                        {
                            if( ( Max( Open[i], Close[i] ) <= High[i - 1] ) && ( Min( Open[i], Close[i] ) >= Low[i - 1] ) ) // Nose body inside Left Eye bar
                            {
                                if( NoseBody / LeftEyeBody <= NoseBodyToLeftEyeBody ) // Nose body to Left Eye body ratio
                                {
                                    if( NoseLength / LeftEyeLength >= NoseLengthToLeftEyeLength ) // Nose length to Left Eye length ratio
                                    {
                                        if( Low[i] - Low[i - 1] >= LeftEyeLength * LeftEyeDepth ) // Left Eye low is low enough
                                        {
                                            if( ( !NoseBodyInsideLeftEyeBody ) || ( ( Max( Open[i], Close[i] ) <= Max( Open[i - 1], Close[i - 1] ) ) && ( Min( Open[i], Close[i] ) >= Min( Open[i - 1], Close[i - 1] ) ) ) ) // Nose body inside Left Eye body if required
                                            {
                                                Down[i] = High[i] + 5 * Point + NoseLength / 5;
                                                brpin[i] = True;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    // Bullish Pinbar
    if( Low[i - 1] - Low[i] >= NoseLength * NoseProtruding ) // Nose protrusion
    {
        if( NoseBody / NoseLength <= MaxNoseBodySize ) // Nose body to candle length ratio
        {
            if( 1 - ( Min( Open[i], Close[i] ) - Low[i] ) / NoseLength < NoseBodyPosition ) // Nose body position in top part of the bar
            {
                if( ( !LeftEyeOppositeDirection ) || ( Close[i - 1] < Open[i - 1] ) ) // Left Eye bearish if required
                {
                    if( ( !NoseSameDirection ) || ( Close[i] > Open[i] ) ) // Nose bullish if required
                    {
                        if( LeftEyeBody / LeftEyeLength >= LeftEyeMinBodySize ) // Left eye body to candle length ratio
                        {
                            if( ( Max( Open[i], Close[i] ) <= High[i - 1] ) && ( Min( Open[i], Close[i] ) >= Low[i - 1] ) ) // Nose body inside Left Eye bar
                            {
                                if( NoseBody / LeftEyeBody <= NoseBodyToLeftEyeBody ) // Nose body to Left Eye body ratio
                                {
                                    if( NoseLength / LeftEyeLength >= NoseLengthToLeftEyeLength ) // Nose length to Left Eye length ratio
                                    {
                                        if( High[i - 1] - High[i] >= LeftEyeLength * LeftEyeDepth ) // Left Eye high is high enough
                                        {
                                            if( ( !NoseBodyInsideLeftEyeBody ) || ( ( Max( Open[i], Close[i] ) <= Max( Open[i - 1], Close[i - 1] ) ) && ( Min( Open[i], Close[i] ) >= Min( Open[i - 1], Close[i - 1] ) ) ) ) // Nose body inside Left Eye body if required
                                            {
                                                Up[i] = Low[i] - 5 * Point - NoseLength / 5;
                                                blpin[i] = True;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

for( i = 1; i < BarCount; i++ )
{
    if( blpin[i] ) PlotText( "bull.pin " , i, L[ i ] - 2.5, colorLime );

    if( brpin[i] ) PlotText( " bear pin" , i, H[ i ] + 2.5, colorOrange );
}

PlotShapes( shapeHollowSmallSquare*brpin, 4, 0, H , 5 );
PlotShapes( shapeHollowSmallSquare*blpin, 5, 0, L , -5 );

Filter = brpin OR blpin;
AddColumn( brpin, "Bearish Pin", 1.2 );
AddColumn( blpin, "Bullish Pin", 1.2 );

_SECTION_END();

Sunday, 1 March 2020

তার যোগ্যতার কারনে অনেক স্মার্ট মানির পছন্দের শীর্ষে আস্তে পারে

#HAKKANIPUL- তার  যোগ্যতার কারনে অনেক স্মার্ট মানির পছন্দের শীর্ষে আস্তে পারে


চার্ট প্যাটার্ন অনুসারে এই শেয়ারেরে একটা গ্রোথ আসবে সামনে , যা সাধারণ ভাবে কারো ই চোখে পরার নয় , কারন সব কিছু সবার চোখে ধরা পরবে না এটাই স্বাভাবিক । আপনি তখই ই দেখতে পারবেন যখন এটাই বাস্তব রূপদান  হবে।

তার ব্যবসায়িক পরিসর আগের থেকে অনেক বাড়ছে , তাই এর থেকে সুফল আসবেই ...

সুফলটা হয়তো আস্তে আস্তে ভয়ংকর রূপ দান করবে এক সময় ... এখন কিন্তু তার ইফেক্ট পরতে শুরু করেছে ,কিন্তু তা আপনার চোখে এখন ধরা পরছে না । তার ইতিমদ্ধে ইপিএস এ গ্রোথ আস্তে শুরু করেছে ...। সে তার লস রিকাভার করতে শুরু করছে ... আশা করা যাচ্ছে খুব শুগ্রই তার ইপিএস এ পজেটিভ ফিগার ফিরে পাবে ।
এই শেয়ারের ফিউচার আপনার আমার কারোর পক্ষে ই প্রেডিক্ট করা সম্ভব না । কারন এই মার্কেট আর শেষটা কোথায় সেটা কেউ জানে না , এটা কেবল ডিমান্ড এন্ড সাপ্লাই আর ভীত্তিতে তার প্রাইচ নির্ধারণ করা হয়ে থাকে । এই কারনেই অনেক শেয়ারের প্রাইচ ১০ টাকার শেয়ার ২ টাকার ও নীচে এবার ১০ টাকার শেয়ার ২০০০ টাকার ও উপরে ।
এই শেয়ার এর ও একটা কাল্পনিক প্রাইচ ধরে নিলাম তিন ডিজিট (৯৯৯) টাকা । কারন আমি জানি না    তিন ডিজিট এর মধ্যে কোথায় তার অবস্থান হতেপারে আর তাই এখানে ৯৯৯ টাকা ধরে রাখলাম । দেখার বিষয় কোথায় যায় এই শেয়ার প্রাইচ । হয়তো সময় একটু বেশী নিতেই পারে কিন্তু এই শেয়ারের প্রাইচ অনেক অনেক দূরে ই যাবে । যার তার নিজের যোগ্যতায় । তার  যোগ্যতার কারনে অনেক স্মার্ট মানির পছন্দের শীর্ষে আস্তে পারে এই শেয়ারের নাম , তার তখন তাদের ইচ্ছা অনুসারে এই শেয়ারের একটা প্রাইচ নির্ধারণ করবেন , কোম্পানির ফান্ডামেন্টাল পরিবর্তনের সাথে সাথে , নতুন নতুন সিদ্ধান্তের কারনে , নতুন নতুন চুক্তির বাস্তবায়নে। সময়ের সাথে সাথে অনেক অনেক কিছু ই পরিবর্তন হতে ই পারে । তার গ্রোথ যেভাবে হতে থাকবে ......... তার সাথে সাথে তাল মিলিয়ে এই শেয়ারের প্রাইচ এ ও একটা বড় পরিবর্তন আসবে, ইনশাআল্লাহ্‌ ।।