# Fibonacci Retracement Lines

Earlier Fibonacci retracement trend line changes every day. I want Fibonacci retracement lines should change every hour.

``````SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{DATE}} High %g Close %g {{VALUES}}",H ,C ));
Plot( C , "", colorPink, styleLine);
//Plot( H , "", colorRed, styleLine);

SetBarsRequired(86400/Max(1,Interval()));

if( Interval() >= inDaily )
Error( "SET TO INTRADAY INTERVAL !" );

dn = DateNum();
start_of_day = dn != Ref(dn,-1);
HH = ValueWhen( start_of_day, Ref(H,-1));
printf( "High of Last Bar of previous Day: %g", hh );

//Plot( C, "Price", colorDefault, styleBar );
//Plot( hh, "High of Last Bar of previous Day", colorGreen, styleNoRescale );

FBL=ValueWhen(Day()!=Ref(Day(),-1),L);
FBH=ValueWhen(Day()!=Ref(Day(),-1),H);
range=FBH-FBL;

ATP = Max( ( (HH + FBL)/2 ), ((FBL + FBH)/2));

a = HH - FBL ;
b = FBH - FBL;

mn = Max( HH - FBL , FBH - FBL);

Buyabove = ATP + ( mn * 0.236);
LT1 = ATP + ( mn * 0.382);
LT2 = ATP + ( mn * 0.500);
LT3 = ATP + ( mn * 0.618) ;
Sellbelow = ATP - ( mn * 0.236);
ST1 = ATP + ( mn * 0.382);
ST2 = ATP + ( mn * 0.500);
ST3 = ATP + ( mn * 0.618) ;

Plot(ATP,"ATP",colorRose,styleDots,styleLine,styleThick);
Plot(Lt1 ,"LT 1",colorRed,styleLine);
Plot(Lt2 ,"LT 2",colorBlue,styleLine);
Plot(Lt3 ,"LT 3",colorYellow,styleLine);

Plot(Sellbelow ,"Sell",colorGreen,styleLine);
Plot(St1 ,"ST 1",colorRed,styleLine);
Plot(St2 ,"ST 2",colorBlue,styleLine);
Plot(St3 ,"ST 3",colorYellow,styleLine);

StartTime = 102959;
Endtime = 112959;
// these conditions are true when TimeNum of the bar equals startime/endtime
StartBar = tn == StartTime;
EndBar = tn == Endtime;

// on the end bar we read the value of highest high or lowest low since the start bar
myH = ValueWhen( EndBar, HighestSince( StartBar, High ) );
myL = ValueWhen( EndBar, LowestSince( StartBar, Low ) );

range2=myH-myL;
HH1 = ValueWhen( StartBar, Ref(H,-1));

ATP = Max( ( (HH1 + myL)/2 ), ((myL + myH)/2));

mn = Max( HH1 - myL , myH - myL);

Buyabove = ATP + ( mn * 0.236);
LT1 = ATP + ( mn * 0.382);
LT2 = ATP + ( mn * 0.500);
LT3 = ATP + ( mn * 0.618) ;
Sellbelow = ATP - ( mn * 0.236);
ST1 = ATP + ( mn * 0.382);
ST2 = ATP + ( mn * 0.500);
ST3 = ATP + ( mn * 0.618) ;

Plot(ATP,"ATP",colorRose,styleDots,styleLine,styleThick);
Plot(Lt1 ,"LT 1",colorRed,styleLine);
Plot(Lt2 ,"LT 2",colorBlue,styleLine);
Plot(Lt3 ,"LT 3",colorYellow,styleLine);

Plot(Sellbelow ,"Sell",colorGreen,styleLine);
Plot(St1 ,"ST 1",colorRed,styleLine);
Plot(St2 ,"ST 2",colorBlue,styleLine);
Plot(St3 ,"ST 3",colorYellow,styleLine);

StartTime = 112959;
Endtime = 122959;
// these conditions are true when TimeNum of the bar equals startime/endtime
StartBar = tn == StartTime;
EndBar = tn == Endtime;

// on the end bar we read the value of highest high or lowest low since the start bar
myH = ValueWhen( EndBar, HighestSince( StartBar, High ) );
myL = ValueWhen( EndBar, LowestSince( StartBar, Low ) );

range2=myH-myL;
HH1 = ValueWhen( StartBar, Ref(H,-1));

ATP = Max( ( (HH1 + myL)/2 ), ((myL + myH)/2));

mn = Max( HH1 - myL , myH - myL);

Buyabove = ATP + ( mn * 0.236);
LT1 = ATP + ( mn * 0.382);
LT2 = ATP + ( mn * 0.500);
LT3 = ATP + ( mn * 0.618) ;
Sellbelow = ATP - ( mn * 0.236);
ST1 = ATP + ( mn * 0.382);
ST2 = ATP + ( mn * 0.500);
ST3 = ATP + ( mn * 0.618) ;

Plot(ATP,"ATP",colorRose,styleDots,styleLine,styleThick);