【问题标题】:Pine- Script/ Trading View Not able to get the proper code for getting high + buffer valuePine- 脚本/交易视图 无法获得正确的代码以获得高 + 缓冲值
【发布时间】:2021-01-19 00:40:07
【问题描述】:

我正在尝试使用 Pine 脚本执行策略,其中应匹配以下条件并执行 long :

条件:发生交叉(ema10,ema20)和((交叉的高+缓冲区)交叉(ema10,ema20))。 我无法获得 longentry,您能帮忙解决这个问题吗?

下面是我的代码:

study("Crossover and highcrossover", overlay=true)

ema10 = ema(close, 10)
ema20 = ema(close, 20)
psar = sar(0.02,0.02,.2)

crossoverval = crossover(ema10, ema20)

signalhigh = iff(crossoverval == 1, high, na)
highbufferadd = signalhigh + 3.0
plot(signalhigh, title="signalhigh", color = green, linewidth = 1, transp=1)
plot(highbufferadd, title="highbufferadd", color = yellow, linewidth = 1, transp=1)

longentry = crossoverval and (close > highbufferadd)
 
plotshape(series=crossoverval, title="Crossover", style=shape.arrowup, location=location.belowbar, color=green, text="Crossover", size=size.small)
plotshape(series=longentry, title="longentry", style=shape.triangleup, location=location.belowbar, color=green, text="longentry", size=size.small)
plot(ema10, title="Ema 10", color = green, linewidth = 1, transp=1)
plot(ema20, title="Ema 20", color = red, linewidth = 1, transp=1)

【问题讨论】:

    标签: pine-script tradingview-api


    【解决方案1】:
        study("Crossover and highcrossover", overlay=true)
    
    ema10 = ema(close, 10)
    ema20 = ema(close, 20)
    psar = sar(0.02,0.02,0.2)
    
    crossoverval = crossover(ema10,ema20)
    
    signalhigh = iff(crossoverval == 1, high, na)
    highbufferadd = signalhigh + 3.0
    plot(signalhigh, title="signalhigh", color = color.green, linewidth = 1, transp=1)
    plot(highbufferadd, title="highbufferadd", color = color.yellow, linewidth = 1, transp=1)
    
    longentry = crossoverval and (close > highbufferadd)
     
    plotshape(series=crossoverval, title="Crossover", style=shape.arrowup, location=location.belowbar, color=color.green, text="Crossover", size=size.small)
    plotshape(series=longentry, title="longentry", style=shape.triangleup, location=location.belowbar, color=color.green, text="longentry", size=size.small)
    plot(ema10, title="Ema 10", color = color.green, linewidth = 1, transp=1)
    plot(ema20, title="Ema 20", color = color.red, linewidth = 1, transp=1)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-19
      • 1970-01-01
      • 2017-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多