[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Drawing Support and Resistance horizontal lines onintra day chart



PureBytes Links

Trading Reference Links

Can't help with your specific code, but I have attached a previously posted AFL that does provide support and resistance lines.

Terry

G wrote:
 
Friends,

  I have the following requirement.

  I have support and resistance for nifty index (India) for the day. I would like
to draw these lines in the intra day charts. I would like to know how
to draw it. I tried my hands with the AFL but it in vain. I have
attached the sample image of what I am trying to achieve. The yellow
horizontal lines are the support and resistance. I also want them to
be of different color. Can anybody help me out on how to achieve this?
 
 Below is the formula that i have used..

DP=(H+L+C)/3;

R1=(2*DP)-L;

S1=(2*DP)-H;

T1=(R1-S1);

T2=(R1-S1);

R2=DP+T1;

S2=DP-T2;

 

Plot(C,"Close",colorBlack,styleBar);

Plot(R1,"Resistance1",colorRed,styleLine);

Plot(R2,"Resistance2",colorOrange,styleLine);

Plot(S1,"Support1",colorDarkBlue,styleLine);

Plot(S2,"Support2",colorGreen,styleLine);

 

Plot(DP,"Pivot",colorPink,styleLine);

 

Actually what I want is to calculate the support and resistance from closing values of the previous day and draw the linear lines on the intraday chart... The above draws the graph for each candle of the intraday. Also I would like to super impose these lines on the inbuilt price charts of AmiBroker. If mail not clear let me know so that I will try to rephrase my words.

 

Cheers,
Govind



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html




Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

"Pivot Points, Support & Resistance lines";
//This plots all support AND resistance levels

Hi1 = IIf(Month()!=Ref(Month(),-1),Ref(HighestSince(Month()!=Ref(Month(),-1),H,1),-1),0);
Hi = ValueWhen(Month()!=Ref(Month(),-1),Hi1,1);
Lo1 = IIf(Month()!=Ref(Month(),-1),Ref(LowestSince( Month()!=Ref
(Month(),-1), L,1),-1),0);
Lo = ValueWhen(Month()!=Ref(Month(),-1),Lo1,1);
CL1=IIf(Month()!=Ref(Month(),-1),Ref(C,-1),0);
CL = ValueWhen(Month()!=Ref(Month(),-1),CL1,1);
rg = Hi - Lo;
bp = (Hi+Lo+CL)/3;
R1 = (2*bP) - Lo ;
S1 = (2*bP) - Hi;
R2 = bP + rg;
S2 = bP - rg;

Plot(C,"Close",colorBlack,styleCandle);
Plot(bp,"Pivot",colorRed,styleBar);
Plot(R1,"R1",colorBlue,styleBar);
Plot(S1,"S1",colorBlue,styleBar);
Plot(R2,"R2",colorBlue,styleBar);
Plot(S2,"S2",colorBlue,styleBar);


// Automatic Oblique Fibonacci Lines
x = Cum(1);
per = 3;// calibrate the sensitivity
s1=L;s11=H;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2  ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x  -endt ) + bS; 
SU = IIf(x>startt-1,trendlineS,-1e10);
Plot(SU,"SU",colorYellow,styleThick);
Plot(C,"C",1,64);b=BarIndex();
X1=ValueWhen(Cum(IsTrue(SU))==1,b);
Y1=ValueWhen(b==X1,SU);
X2=LastValue(b);Y2=LastValue(SU);
SLOPE=(Y2-Y1)/(X2-X1);
YP=LastValue(Highest(SU/SU*H));
XP=ValueWhen(H==YP,b);
HL0=YP+SLOPE*(b-XP);
DIST=ValueWhen(H==YP,H-SU);
HL1=YP-0.382*DIST+SLOPE*(b-XP);Plot(HL1,"\n0.382",colorRed,1);
HL2=YP-0.5*DIST+SLOPE*(b-XP);Plot(HL2,"\n0.500",colorRed,1);
HL3=YP-0.618*DIST+SLOPE*(b-XP);Plot(HL3,"\n0.618",colorRed,1);
Plot((HL1/HL1)*HL0,"\nRE",colorYellow,styleThick);

/// Plot EMA's ///

VarEMA200 = EMA(C,200);
VarEMA50 = EMA(C,50);
Plot(VarEMA50,"EMA50",colorWhite,styleDots);
Plot(VarEMA200,"EMA200",colorBlack,styleDots);

GraphXSpace=2;