Perfetto, ora sì. Il problema era che hh e ll venivano ricalcolati sempre, mentre vogliamo che lo facciano solo tra time1 e time2.
////
//TF 30 minuti
Time1=13000
Time2=80000
ShowpastFibo = 0
////
IF (openTime = Time1) OR ((openTime > Time1) AND (openTime[1] < Time1)) THEN
Bar1 = barindex
hh = high
ll = low
elsif opentime>time1 and opentime<=time2 then
hh = max(hh,high)
ll = min(ll,low)
endif
IF (openTime = Time2) OR ((openTime > Time2) AND (openTime[1] < Time2)) THEN
Bar2 = BarIndex
// Punti di Fibonacci
ORWidth = hh - ll
FibMid = (hh + ll) / 2
FibExtUp2 = hh + ORWidth * (0.272)
FibExtDown2 = ll - ORWidth * (0.272)
ENDIF
IF ShowpastFibo = 1 and Bar2 > Bar1 THEN
DrawRectangle(Bar1,hh,Bar2,ll) coloured(255,0,0,25) bordercolor(41,98,255,0) style(Line,2)
drawsegment(Bar1,hh,Bar2,hh)coloured("red")style(line,1)
drawsegment(Bar1,ll,Bar2,ll)coloured("green")style(line,1)
drawsegment(Bar1,FibMid,Bar2,FibMid)coloured("blue")style(dottedline,1)
drawsegment(Bar1,ll,Bar2,ll)coloured("green")style(line,1)
drawsegment(Bar1,FibExtDown2,barindex,FibExtDown2)coloured("green")style(dottedline,1)
DRAWTEXT("27.2% #FibExtDown2#",Bar1-6,FibExtDown2,SansSerif,Bold,8)coloured("green")
////
drawsegment(Bar1,FibExtUp2,barindex,FibExtUp2)coloured("red")style(dottedline,1)
DRAWTEXT("27.2% #FibExtUp2#",Bar1-6,FibExtUp2,SansSerif,Bold,8)coloured("red")
Bar2 = 0
elsif ShowpastFibo = 0 and bar2>bar1 and islastbarupdate THEN
DrawRectangle(Bar1,hh,bar2,ll) coloured(255,0,0,25) bordercolor(41,98,255,0) style(Line,2)
drawsegment(bar1,hh,bar2,hh)coloured("red")style(line,1)
drawsegment(Bar1,ll,bar2,ll)coloured("green")style(line,1)
drawsegment(Bar1,FibMid,bar2,FibMid)coloured("blue")style(dottedline,1)
drawsegment(Bar1,ll,bar2,ll)coloured("green")style(line,1)
drawsegment(Bar1,FibExtDown2,bar2,FibExtDown2)coloured("green")style(dottedline,1)
DRAWTEXT("27.2% #FibExtDown2#",Bar1-6,FibExtDown2,SansSerif,Bold,8)coloured("green")
drawsegment(Bar1,FibExtUp2,bar2,FibExtUp2)coloured("red")style(dottedline,1)
DRAWTEXT("27.2% #FibExtUp2#",Bar1-6,FibExtUp2,SansSerif,Bold,8)coloured("red")
endif
return