Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Support/Resistance Modified for Amibroker (AFL)

Rating:
2 / 5 (Votes 7)
Tags:
amibroker, support, resistance

Revised Support and Resistance, removed duplicate support and resistance levels and removed excess code.

Screenshots

Similar Indicators / Formulas

Intraday Trades
Submitted by vishalsbharati over 7 years ago
Support & Resistance
Submitted by shyam242 over 8 years ago
Tom DeMark Trend Lines
Submitted by kaiji over 9 years ago
Support and resistance range
Submitted by mediaworks over 8 years ago

Indicator / Formula

Copy & Paste Friendly
   SetChartOptions(0,chartShowDates);
   SetChartBkColor(16);
   GraphXSpace=Param("GraphXSpace",10,-100,100,1);
   SetBarFillColor(IIf(O>C,24,19));
   Plot(C,"Price",IIf(O>C,32,34),64);
   dtn=DateNum();
   haC=EMA((O+H+L+C)/4,3);    haO=AMA(Ref(haC,-1),0.5);
   haH=Max(H,Max(haC,haO));   haL=Min(L,Min(haC,haO));
_SECTION_BEGIN("Name");
   GfxSetOverlayMode(1);
   pxh= Status("pxHeight");  pxw=Status("pxWidth");
   GfxSelectFont("Tahoma",pxh/8);
   GfxSetTextColor(ColorHSB(42,42,42));
   GfxSetTextAlign(6);  GfxSetBkMode(0);
   GfxTextOut(Name(),pxw/2,pxh/12);
   GfxSelectFont("Tahoma",pxh/18);
   GfxTextOut(IndustryID(1),pxw/2,pxh/4);
   GfxSelectFont("Tahoma",pxh/18);
   GfxSelectFont("Tahoma",pxh/36);
   GfxTextOut("Sup/Res",pxw/2,pxh/3);
_SECTION_END();
//==============================
_SECTION_BEGIN("HL Pivots");
//==============================
   psh= ParamToggle("Pivot Shapes","Off|On",1);
   plb= ParamToggle("Pivot Labels","Off|On",1);
   snd= ParamToggle("Sound Alerts","Off|On",1);
   lbk= Param("Hi Lo Lookback",350,50,5000,10);
   nbz= Param("Swing Bars",20,5,150,1);
   tht= Param("Hi Label Adjust",0.65,0.10,5,0.05)*ATR(5);
   lbk= Min(BarCount-1,Lbk);
   bc=BarCount-1;
//================
   xH=H-H;   xL=L-L;   yH=H-H;   yL=L-L;   xR=H-H;   xS=L-L;
   xrb=0;    xSb=0;    yR0=0;    yS0=0;    xR0=0;    xS0=0;   xx=0;
   xHH= HHVBars(H,nbz);  xLL= LLVBars(L,nbz);
   yHH= HHV(H,nbz);      yLL= LLV(L,nbz);
   viz= Status("BarVisible");
   vbz= LastValue(Highest(IIf(viz,BarIndex(),0)));
   _TRACE("Last visible bar: "+ vbz);
   bct= (BarCount-1);  dir = "";
   if(xLL[bc]<xHH[bc])  { dir="D"; } else { dir="U"; }
    for(i=0; i<lbk; i++)  {  bc=bct-i;
     if(xLL[bc]<xHH[bc])  { if(dir=="U"){dir="D";
      xx=bc-xLL[bc];  xL[xx]=1;  
      yL[xSb]=L[xx];  xS[xSb]=xx; xSb++; }
     } else { if(dir=="D")  { dir = "U";
        xx=bc-xHH[bc];  xH[xx]=1;  yH[xrb]=H[xx];  xR[xrb]=xx;xrb++; }}}
        xP= 0;  yP= 0;  xS0= xS[0];  yS0=yL[0];  xR0= xR[0];  yR0= yH[0];
     if(xS0>xR0) { xP=bc-xHH[bc];  yP= yHH[bc];
      if(yR0<yP AND xP>xS0 AND xP<bc) {  xH[xP]=1;
       for(j=0; j<xrb; j++) { yH[xrb-j]= yH[xrb-(j+1)];
        xR[xrb-j]= xR[xrb-(j+1)];  }
        yH[0]= yP;  xR[0]= xP;  xrb++;  }
        } else { xP= bc-xLL[bc]; yP= yLL[bc];
           if(yS0>yP AND xP>xR0 AND xP<bc) {  xL[xP]=1;
            for(j=0; j<xSb; j++) { yL[xSb-j]= yL[xSb-(j+1)];  xS[xSb-j]= xS[xSb-(j+1)];  }
             yL[0]=yP;  xS[0]=xP;  xSb++;  }}
   ushp=shapeHollowUpArrow;   dshp=shapeHollowDownArrow;
   if(psh) { PlotShapes(xH*dshp,42,0,H,-10);  PlotShapes(xL*ushp,43,0,L,-10); }
   if(snd) {
    AlertIf(xL==1,"SOUND C:\\Windows\\Media\\Windows XP Startup.wav","Audio alert",2);
    AlertIf(xH==1,"SOUND C:\\Windows\\Media\\Ringin.wav","Audio alert",2);  }
   Buy=(xL);  Sell=(xH);  Cover=(xL);  Short=(xH); Long=Flip(Buy,Sell);  Shrt=Flip(Sell,Buy);
   SellPrice=ValueWhen(Sell,H,1);  BuyPrice= ValueWhen(Buy,L,1);
   if(plb) {
    for(i=0; i<BarCount; i++) { 
     if(Buy[i] )PlotText("\n\n"+ StrRight(NumToStr(L[i],6.2),5),i-1,L[i],43,16); 
     if(Sell[i])PlotText(StrRight(NumToStr(H[i],6.2),5),i-1,H[i]+tht[i],32,16); }
   }
_SECTION_END();
//===========================
_SECTION_BEGIN("Sup & Res");
//===========================
   plt= ParamToggle("Sup_Res","Off|On",1);
   rpd= Param("Res Periods",2,0,200,1);
   spd= Param("Sup Periods",2,0,200,1);
   rsc= ParamToggle("Sup_Res","Off|On",1)*2048;
   sty= ParamStyle("Style",1)|rsc;
   rco= ParamColor("Res Color",22);
   sco= ParamColor("Sup Color",22);
   if(plt){
    pma= TEMA(H,rpd);
    pk= pma>Ref(pma,-1)AND Ref(pma,1)<H;//Peak
    yp0= ValueWhen(pk,haH,0);
    yp1= ValueWhen(pk,haH,1);
    yp2= ValueWhen(pk,haH,2);
    pkM= yp2<yp1 AND yp1>yp0;   prq=Ref(pkM,-1)==0 AND pkM==1;//MajorPeak
    yR1= ValueWhen(prq,yp1,1);  xR1= ValueWhen(prq,dtn,1);
    yR1= IIf(dtn<SelectedValue(xR1),Null,SelectedValue(yR1));
    yR2= ValueWhen(prq,yp1,2);  xR2= ValueWhen(prq,dtn,2);
    yR2= IIf(dtn<SelectedValue(xR2),Null,SelectedValue(yR2));
    yR3= ValueWhen(prq,yp1,3);  xR3= ValueWhen(prq,dtn,3);
    yR3= IIf(dtn<SelectedValue(xR3),Null,SelectedValue(yR3));
    yR4= ValueWhen(prq,yp1,4);  xR4= ValueWhen(prq,dtn,4);
    yR4= IIf(dtn<SelectedValue(yR4),Null,SelectedValue(yR4));
    yR5= ValueWhen(prq,yp1,5);  xR5= ValueWhen(prq,dtn,5);
    yR5= IIf(dtn<SelectedValue(xR5),Null,SelectedValue(yR5));
    yR6= ValueWhen(prq,yp1,6);  xR6=ValueWhen(prq,dtn,6);
    yR6= IIf(dtn<SelectedValue(xR6),Null,SelectedValue(yR6));
    Plot(yR1,"R1",rco,1);
    Plot(IIf(yR2!=yR1,yR2,Null),"R2",rco,sty);  
    Plot(IIf(yR3!=yR2 AND yR3!=yR1,yR3,Null),"R3",rco,sty);
    Plot(IIf(yR4!=yR3 AND yR4!=yR2 AND yR4!= yR1,yR4,Null),"R4",rco,sty);  
    Plot(IIf(yR5!=yR4 AND yR5!=yR3 AND yR5!=yR2 AND yR5!=yR1,yR5,Null),"R5",rco,sty);
    Plot(IIf(yR6!=yR5 AND yR6!=yR4 AND yR6!=yR3 AND yR6!=yR2 AND yR6!=yR1,yR6,Null),"R6",rco,sty);
//=========================
//======== SUPPORT ========
//=========================
    tma= TEMA(L,spd);   
    tr= Ref(tma,1)>L AND tma<Ref(tma,-1);//Trough
    yt0= ValueWhen(tr,haL,0);
    yt1= ValueWhen(tr,haL,1);
    yt2= ValueWhen(tr,haL,2);
    trM= yt2>yt1 AND yt1<yt0;
    psq= Ref(trM,-1)==0 AND trM==1;
    yS1= ValueWhen(psq,yt1,1);  xS1= ValueWhen(psq,dtn,1);
    yS1= IIf(dtn<SelectedValue(xS1),Null,SelectedValue(yS1));
    yS2= ValueWhen(psq,yt1,2);  xS2= ValueWhen(psq,dtn,2);
    yS2= IIf(dtn<SelectedValue(xS2),Null,SelectedValue(yS2));
    yS3= ValueWhen(psq,yt1,3);  xS3= ValueWhen(psq,dtn,3);
    yS3= IIf(dtn<SelectedValue(xS3),Null,SelectedValue(yS3));
    yS4= ValueWhen(psq,yt1,4);  xS4= ValueWhen(psq,dtn,4);
    yS4= IIf(dtn<SelectedValue(xS4),Null,SelectedValue(yS4));
    yS5= ValueWhen(psq,yt1,5);  xS5= ValueWhen(psq,dtn,5);
    yS5= IIf(dtn<SelectedValue(xS5),Null,SelectedValue(yS5));
    yS6= ValueWhen(psq,yt1,6);  xS6= ValueWhen(psq,dtn,6);
    yS6= IIf(dtn<SelectedValue(xS6),Null,SelectedValue(yS6));
    Plot(yS1,"S1",sco,sty);  
    Plot(IIf(yS2!=yS1,yS2,Null),"S2",sco,sty);  
    Plot(IIf(yS3!=yS2 AND yS3!=yS1,yS3,Null),"S3",sco,sty);
    Plot(IIf(yS4!=yS3 AND yS4!=yS2 AND yS4!= yS1,yS4,Null),"S4",sco,sty);  
    Plot(IIf(yS5!=yS4 AND yS5!=yS3 AND yS5!=yS2 AND yS5!=yS1,yS5,Null),"S4",sco,sty);
    Plot(IIf(yS6!=yS5 AND yS6!=yS4 AND yS6!=yS3 AND yS6!=yS2 AND yS6!=yS1,yS6,Null),"S4",sco,sty);
   }
_SECTION_END();

9 comments

1. tigernifty

dear sir,
am facing fill colour error,,,pls guide me.. thx..
S.SURESH..ERODE.TAMILNADU…9842406366

2. mahesh.aranake

Dear Admin,
Does this formula look into future while giving buy sell signals?

3. administrator

Hello

Yes, it looks like it does.

4. prakash2009

It gives signals after 4 candles.Better for postmartem.

5. hoierman

In doing Exploration I can’t seem to get a BUY signal … all SELL

What do I need as the BUY criteria??

Dick H
emal: areehoi@yahoo.com

6. hoierman

Administrator:
I’m not getting any response from prior comment on how to get Buy signals from Exploration. Would it b possible to put me in touch with the author so it could be resolved. Many thanks

Dick Hoierman

7. administrator

Hello hoierman

I can’t give that information due to the privacy policy but I’m pretty sure that someone at the Amibroker yahoo group would be able to help if you ask there.

8. pakkunet

This is because the exploration code is missing. The indicator was developed for a visual inspection via a plot on chart.

Since the code uses zigzag routines ( that looks into the future) using this as an exploration tool can be hazardous to your trading account too!

Here are the snippets of the code

nbz= Param(“Swing Bars”,20,5,150,1); xHH= HHVBars(H,nbz); xLL= LLVBars(L,nbz); yHH= HHV; yLL= LLV;

All this does is find the highest high and lowest low of the previous 20 bars. When new data comes in from the future automatically the signals will change.

This formula is best used for the support and resistance lines and best left at that.

9. muoixd

Dear Admin,
Could you please kindly help me check why in my chart the signal just can appear for 2 days in M1, 7days in M5, 18days in M15, 60days in H1?

Leave Comment

Please login here to leave a comment.

Back