hi, this a code to draw the Initial balance in my time zone, i need it to stop drawing when market closes .
Some Help?
DEFPARAM DrawOnLastBarOnly = true
//timeframe(1 hour)// I declare the timeframe, if not this will give the high and low of the first candle of the timefrae selected
StartTime = 143000// this is my zone start time
EndTime = 153000
IF OpenTime = StartTime OR ((OpenTime > StartTime) AND (OpenTime < OpenTime[1])) THEN
myBar = BarIndex
HH = high
LL = low
ENDIF
IF (OpenTime >= StartTime) AND (OpenTime <= EndTime) THEN
HH = max(HH,high)
LL = min(LL,low)
ENDIF
IF OpenTime >= EndTime THEN
DrawSegment(myBar,HH,BarIndex,HH) coloured("Green",255)
DrawSegment(myBar,LL,BarIndex,LL) coloured("Red",255)
//lastsig = 1
ENDIF
//if Endtime > 220000 then
//lastsig = 0
//endif
RETURN HH AS "IB 1Hr High",LL AS "IB 1Hr Low"
Hi,
here’s one possible way to do it, on one hand keeping your combo drawonlastbaronly=true & drawsegments for live, and on the other hand keeping hh and ll values in the return line to have them available for color zone customisation in the properties window (assuming you want to keep the color zone as per your attached image even if the zone stops at midnight your timezone):
DEFPARAM DrawOnLastBarOnly = true
//timeframe(1 hour)// I declare the timeframe, if not this will give the high and low of the first candle of the timefrae selected
StartTime = 143000// this is my zone start time
EndTime = 153000
IF OpenTime = StartTime OR ((OpenTime > StartTime) AND (OpenTime < OpenTime[1])) THEN
myBar = BarIndex
HH = high
LL = low
ENDIF
IF (OpenTime >= StartTime) AND (OpenTime <= EndTime) THEN
HH = max(HH,high)
LL = min(LL,low)
ENDIF
alpha=0
IF OpenTime >= EndTime then
DrawSegment(myBar,HH,BarIndex,HH) coloured("Green",255)
DrawSegment(myBar,LL,BarIndex,LL) coloured("Red",255)
//lastsig = 1
alpha=255
elsif opentime<StartTime then
hh=ll
ENDIF
//if Endtime > 220000 then
//lastsig = 0
//endif
RETURN HH coloured("Green",alpha) AS "IB 1Hr High", LL coloured("Red",alpha) AS "IB 1Hr Low"