【问题标题】:Modifying Pine script for stock trading修改用于股票交易的 Pine 脚本
【发布时间】:2020-06-12 17:08:35
【问题描述】:

我对 pine 脚本一无所知,我什至不知道任何编程语言。

我需要一个指标,通过直方图显示两个不同值指数移动平均线之间的差异。

我尝试修改类似公共指标的脚本,该指标使用直方图衡量价格和指数移动平均线之间的差异。

原文:

//@version=3
study("My Script")
emaVal = input(12, "EMA Value")
varPrice = input(ohlc4, "Price")
varEMA = ema(varPrice, emaVal)

showEMA = input(false)
showPrice = input(false)
showHistogram = input(true)

output = varPrice - varEMA

plot(showEMA ? varEMA : na, color=blue)
plot(showPrice ? varPrice : na, color=purple)
plot(showHistogram and (varPrice > varEMA) ? output : na, color=green, linewidth=4, style=histogram)
plot(showHistogram and (varEMA > varPrice) ? output : na, color=red, linewidth=4, style=histogram)

我想做什么:

//@version=3
study("Hello")

emaVal = input(60, "EMA 1 Value")
emaVal = input(240, "EMA 2 Value")
varEMA = ema(emaVal, emaVal)


showHistogram = input(true)

output = emaVal2 - emaVal


plot(showHistogram and (emaVal > emaVal) ? output : na, color=green, linewidth=4, style=histogram)
plot(showHistogram and (emaVal2 > emaVal) ? output : na, color=red, linewidth=4, style=histogram)

请不要惊慌,我只是在完全不知道任何事情的情况下尝试按照逻辑行事。有人可以帮助我实现该脚本吗?

额外的问题:请你能给我一个可以学习 Pine 脚本的资源吗?我在谷歌上搜索,但有很多垃圾和试图卖东西的人。我通过交易视图尝试了手册,但我不知道很多单词的含义。

【问题讨论】:

    标签: pine-script trading


    【解决方案1】:

    如果您对代码有任何疑问,请询问:

    //@version=4
    study("Hello")
    i_emaFastP  = input( 60,    "Fast EMA Period")
    i_emaSlowP  = input(240,    "Slow EMA Period")
    i_emaSrc    = input(close,  "Source", type = input.source)
    i_showHist  = input(true,   "Show Histogram")
    i_showEmas  = input(false,  "Show EMAs")
    
    emaFast     = ema(i_emaSrc, i_emaFastP)
    emaSlow     = ema(i_emaSrc, i_emaSlowP)
    emaDelta    = emaFast - emaSlow
    
    plot(i_showEmas ? emaFast  : na, "emaFast", color.fuchsia)
    plot(i_showEmas ? emaSlow  : na, "emaSlow", color.blue)
    plot(i_showHist ? emaDelta : na, "Hist",    emaDelta > 0 ? color.lime : color.red, 4, plot.style_histogram)
    

    【讨论】:

    • 非常感谢。
    【解决方案2】:

    好吧,您已经定义了两次emaVal(第 4 行和第 5 行)...您可能打算在第 5 行使用 emaVal2

    同样在第 14 行,您正在检查 emaVal 是否大于自身:emaVal > emaVal(始终为假)。我猜你打算这样做emaVal > emaVal2

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-11
      相关资源
      最近更新 更多