我想获得2个条目之间的最高点(例如2个ema十字之间,如图像示例)。它在我头上,我barssince()
没有运气就尝试过。任何帮助都将受到欢迎!
//@version=4
study("My Script", overlay = true)
ema1 = ema(close, 20)
ema2 = ema(close, 50)
plot(ema1)
plot(ema2, color = color.yellow)
buy = crossover(ema1, ema2)
sell = crossunder(ema1, ema2)
highest_buy = highestbars(high, barssince(buy))
plot(highest_buy)
连续剧情:
//@version=4
study("My Script", overlay = true)
var bool track = false
var float highest_buy = na
ema1 = ema(close, 20)
ema2 = ema(close, 50)
buy = crossover(ema1, ema2)
sell = crossunder(ema1, ema2)
if buy
track := true
else if sell
track := false
highest_buy := track ? max(nz(highest_buy), high) : na
plot(ema1)
plot(ema2, color=color.yellow)
plot(highest_buy, color=color.purple, style=plot.style_linebr)
仅绘制最新出现的图:
//@version=4
study("My Script", overlay = true)
var bool track = false
var float highest_buy = na
var int bar_buy = na
var int bar_sell = na
var line hline = line.new(na, na, na, na, extend=extend.both, color=color.purple)
ema1 = ema(close, 20)
ema2 = ema(close, 50)
buy = crossover(ema1, ema2)
sell = crossunder(ema1, ema2)
if buy
track := true
bar_buy := bar_index
highest_buy := track ? max(nz(highest_buy), high) : na
if sell
track := false
bar_sell := bar_index
line.set_xy1(hline, bar_buy, highest_buy)
line.set_xy2(hline, bar_sell, highest_buy)
plot(ema1)
plot(ema2, color=color.yellow)
bgcolor(buy ? color.green : na, transp=80)
bgcolor(sell ? color.red : na, transp=80)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句