繁体   English   中英

plot 系列第一根柱线的超级趋势收盘价(多头/空头)怎么办?

[英]how can i plot series first bar's close price of super trend (long/short)?

plot 系列第一根柱线的超级趋势收盘价(多头/空头)怎么办? //@version=5 指标("Supertrend", overlay=true, timeframe="", timeframe_gaps=true)

atrPeriod = input(10, "ATR Length")
factor = input.float(3.0, "Factor", step = 0.01)

[supertrend, direction] = ta.supertrend(factor, atrPeriod)

bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green,      style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red,     style=plot.style_linebr)

fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)
var float first_close = 0.
if barstate.isfirst
    first_close := supertrend

每当方向变为变量时,您都必须保存收盘价,然后您可以 plot 该变量。 下面的例子

//@version=5 
indicator("Supertrend", overlay=true, timeframe="", timeframe_gaps=true)
atrPeriod = input(10, "ATR Length")
factor = input.float(3.0, "Factor", step = 0.01)

[supertrend, direction] = ta.supertrend(factor, atrPeriod)

bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green,      style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red,     style=plot.style_linebr)

fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)
var firstbarsclose=close
if direction<0 and direction[1]>0
    firstbarsclose:=close
if direction>0 and direction[1]<0
    firstbarsclose:=close
plot(firstbarsclose,style=plot.style_stepline)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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