简体   繁体   中英

Pincescript to get the average of high and low values

I got the below code from the trading view. How can I add another average line of the High and Low from the Marked.

Example: The below code marks the graph the Highest and the Lowest points from the 30 minutes candles in 5 minutes time frame. So, I would like to add another line average of both of the high and low.

study(title="ORB-30Min", shorttitle="ORB30", overlay=true)
up30on = input(true, title="35 Minute Opening Range High")
down30on = input(true, title="35 Minute Opening Range Low")

is_newbar(res) => change(time(res)) != 0 

adopt(r, s) => security(tickerid, r, s) 

high_range = valuewhen(is_newbar('D'),high,0)
low_range = valuewhen(is_newbar('D'),low,0)

high_rangeL = valuewhen(is_newbar('D'),high,0) 
low_rangeL = valuewhen(is_newbar('D'),low,0) 

//averaged = (high_rangeL + low_rangeL)/2

up30 = plot(up30on ? adopt('30', high_rangeL): na, color = #333fff, style=line, linewidth=1) 
down30 = plot(down30on ? adopt('30', low_rangeL): na, color = #333fff, style=line, linewidth=1) 

//ave = plot(down30on ? adopt('30', low_rangeL): na, color = #e97d53, style=line, linewidth=1) 


trans30 = up30on ?  97 : 100
fill(up30, down30, color = white, transp=trans30)
//@version=4
study(title="ORB-30Min", shorttitle="ORB30", overlay=true)

up30on = input(true, title="35 Minute Opening Range High")
down30on = input(true, title="35 Minute Opening Range Low")
avg30on = input(true, title="35 Minute Opening Range Average")

is_newbar(res) => change(time(res)) != 0 

adopt(r, s) => security(syminfo.tickerid, r, s) 

high_range = valuewhen(is_newbar('D'),high,0)
low_range = valuewhen(is_newbar('D'),low,0)

high_rangeL = valuewhen(is_newbar('D'),high,0) 
low_rangeL = valuewhen(is_newbar('D'),low,0) 


up30 = plot(up30on ? adopt('30', high_rangeL): na, color = #333fff, style=plot.style_stepline, linewidth=1) 
down30 = plot(down30on ? adopt('30', low_rangeL): na, color = #333fff, style=plot.style_stepline, linewidth=1) 

avg30 = plot(avg30on ? adopt('30', avg(high_rangeL,low_rangeL)): na, color = #e97d53, style=plot.style_stepline, linewidth=1) 

color30 = up30on ?  color.new(color.white,97) : color.new(color.white,100)
fill(up30, down30, color = color30)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM