Hi! I want to make an indicator to plot horizontal lines with manual input, but between specific times of the day. In detail, I want to have the option to put my preferred start time and end time of the day, and on those duration to have the option to put manual my prices for horizontal lines. As an extra, I will be happy if these lines has auto dynamic color (green>last price, red<last price) versus the last price. The lines I want to end at the end time. Something like the pivot points.. Can someone help me, please..
There you go:
//DEFPARAM DrawOnLastBarOnly = true
//FromHour = 0
//ToHour = 120000
//Price = 0
ONCE PlotFlag = 0
IF (OpenTime = FromHour) OR ((OpenTime > FromHour) AND (OpenTime[1] < FromHour)) THEN
PlotFlag = 1
StartBar = BarIndex
ENDIF
IF PlotFlag > 0 THEN
EndBar = BarIndex
r = 255 //Red
g = 0
IF close > Price THEN
r = 0
g = 202 //Green
ENDIF
DRAWSEGMENT(StartBar,Price,EndBar,Price) coloured(r,g,0,255)
ENDIF
IF ((OpenTime >= ToHour) OR (Price <= 0)) AND (PlotFlag = 1) THEN
PlotFlag = 0
EndBar = BarIndex
ENDIF
RETURN
You can import the attached ITF file with variables already set for the properties. If you pefer to Copy & Paste remove comments from lines 2-4.
Hey robertogozzi
It is possible to add a little text to that horizontal lines??????
There you go, replace XXXXXX with your text:
DEFPARAM DrawOnLastBarOnly = true
//FromHour = 0
//ToHour = 120000
//Price = 0
//Distance = 10
ONCE PlotFlag = 0
IF (OpenTime = FromHour) OR ((OpenTime > FromHour) AND (OpenTime[1] < FromHour)) THEN
PlotFlag = 1
StartBar = BarIndex
ENDIF
IF PlotFlag > 0 THEN
EndBar = BarIndex
r = 255 //Red
g = 0
IF close > Price THEN
r = 0
g = 202 //Green
ENDIF
DRAWSEGMENT(StartBar,Price,EndBar,Price) coloured(r,g,0,255)
DRAWTEXT("XXXXXX",BarIndex,Price + Distance * PipSize)
ENDIF
IF ((OpenTime >= ToHour) OR (Price <= 0)) AND (PlotFlag = 1) THEN
PlotFlag = 0
EndBar = BarIndex
ENDIF
RETURN
I added variable Distance to plot the text at a distance from the line (it can be negative to plot below the line).
Oh! Thank you again!!! Very good and fast answer!!!!