'horizontal line next to specif bar to indicates the half of that bar
Good morning everyone, I cannot create a code that, upon the occurrence of the first condition, which colors the bar green or red, draws a horizontal line next to this bar that indicates the precise half of that bar. Thanks to those who want to help me
This is my code, but this is my code, but unfortunately it doesn't print any lines:
//@version=5
indicator("P_O", overlay=true)
leftBars = 4 //left strenght
rightBars = 0 //right strenght
swh = ta.pivothigh(leftBars, rightBars)
swl = ta.pivotlow(leftBars, rightBars)
swh_cond = not na(swh)
swl_cond = not na(swl)
//--------------------------------------------Identifica High & Low------------------------------------------------------------------
lBars = 4 //left strenght
rBars = 4 //right strenght
awh = ta.pivothigh(lBars, rBars)
awl = ta.pivotlow(lBars, rBars)
awh_cond = not na(awh)
awl_cond = not na(awl)
//-----------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------Signal_Green_Long----------------------------------------------------------------------
barcolor(close > open and swl_cond and ((close - low) / (open - low)) > (75/100) and ((close - low) / (open - low)) < (300/100) and ((high - close) / (open - low)) < (50/100) ? #008000 : na)
//Stampa avviso segnale
Signal_Green_Long = (close > open and swl_cond and ((close - low) / (open - low)) > (75/100) and ((close - low) / (open - low)) < (300/100) and ((high - close) / (open - low)) < (50/100))
plotshape (Signal_Green_Long, text='Segnale Long',color=#008000)
//-----------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------stampa 1/2 candela---------------------------------------------------------------------
half= ((high-low)/2)
t1 = ta.valuewhen(Signal_Green_Long,(high-low)/2,0)
plot(t1, color=t1 != t1[1] ? na : color.black)
//-----------------------------------------------------------------------------------------------------------------------------------
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
