PureBytes Links
Trading Reference Links
|
Hi Burwell,
Please find, here after, the detailed code in Easy Language to perform a n%
fibo retracement.
First we have to agree on the 2 points A and B on which we are going to
compute the retracement.
In my first ELA file I was using an envelop on a P&F chart.
In the same idea I will now use a channel breakout ( some people use
a plain % from a certain point ( pivot per example) but I prefer to know
the size of the leg on which I am going to compute the retracement.
The start is to have an indicator which gives you the starting point (A)of
the previous trend and the provisory ending point of this trend ( B).
Thus you get 2 points ( leg A/B) on which you can draw different levels of
Fibo retracements.
The channel ( as a volatility breakout indicator) is a good point to start
you will have to adjust the length of the lookback to adjust the channel to
your own time horizon ( intraday, daily, weekly, etc...).
Code :
Input : LookBack ( N), Fibo(0.68) Fibo() could be any level of
retracement
you may choose
Var : HP(0),LP(0); HP/LP ( highest High /lowest Low of
channel between 2 changes
of direction
Var : DirP(0),DirN(0); Positive/negative direction
Var : BegH(0),BegL(0); Beginning value of High/low when new
direction changes
(breakout of channel )
Var : LastH(0),LastL(0) Last Highest High or Lowest Low
Var : FiboP(0),FiboN(0); Estimated level of Pos/Neg
retracement
{ 1° perform channel High and low levels }
HP=highest(H,Lookback);
LP=lowest(Low,lookback);
{ 2° perform change of direction }
if close>HP then DirP=1;
if close<LP then DirN=-1;
if close>HP then DirN=0;
if close<LP then DirP=0;
{ 3° register beginning High and low when change of direction and keep last
Highest H or Lowest Low for further needs ,adjust BegH and begL according to
price levels}
if dirP=1 and DirN[1]= -1 then begin
begH=high;
LastH=begH[1];
end;
if dirN= -1 and DirP[1]=1 then begin
begL=Low;
LastL=begL[1];
end;
if dirP=1 and dirP[1]=1 then begin
if high>begH then begH=High;
end;
if dirN= -1 and dirN[1]= -1 then begin
if Low<begL then begL=Low;
end;
{ 4° perform levels FiboP and Fibo N }
if dirN= -1 then FiboP=begL+((begH-begL)*fibo);
if dirP=1 then FiboP=begL+((lastH-begL)*Fibo);
if dirN= -1 then FiboN=begH-((begH-LastL)*fibo);
if dirP=1 then FiboN=begH-((begH-begL)*Fibo);
{You may round () the figures of FiboP and
Fibo N}
{ 5° Plot FiboP and FiboN }
Plot1(FiboP,"fiboP");
Plot2(FiboN,"FiboN")
NB If you want to trace the different figures used along in this indicator,
to better understand how it works you may plot too :
DirP,DirN ( I use histogram plot), BegH,begL,LastH,LastL
I hope these explanations will help you and I forward the same message to
the group in case of somebody else could be interested in it.
Regards. Paul
|