【问题标题】:Error coming as undeclared identifier 'buy'; and undeclared identifier 'sell'作为未声明的标识符“购买”出现的错误;和未声明的标识符“卖”
【发布时间】:2021-08-31 14:59:34
【问题描述】:

代码

//@version=4 
strategy("Sagargy1") 
fast=20
slow=50 
fastMA= ema(close, fast) 
slowMA= ema(close, slow) 
strategy.entry("Buy", strategy.long, when=close[0] > close [1] and fastMA > slowMA and close[0]>vwap) 
strategy.entry("Sell", strategy.short, 10, when=close[0] < close [1] and fastMA < slowMA and close[0]<vwap) 
plot(Buy, color=color.green) 
plot(Sell, color=color.red)
plot(Buy, color=color.green)
plot(Sell, color=color.red)

【问题讨论】:

    标签: pine-script algorithmic-trading tradingview-api


    【解决方案1】:

    我更正了你的代码,你可以在这里看到它https://www.tradingview.com/x/oERRUXom/,你不需要在收盘后添加零,因为这指的是图表中的最后一根蜡烛。接近零意味着接近

    //@version=4 
    
    strategy("Sagargy1", overlay=true) 
    fast=20, slow=50 
    
    fastMA= ema(close, fast) 
    slowMA= ema(close, slow) 
    
    strategy.entry("Buy", strategy.long, when=close > close [1] and fastMA > slowMA and close>vwap) 
    strategy.entry("Sell", strategy.short, when=close < close [1] and fastMA < slowMA and close<vwap) 
    
    
    plot(fastMA, color=color.green) 
    plot(slowMA, color=color.red) 
    

    【讨论】:

    • 非常感谢先生。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-12
    • 1970-01-01
    • 1970-01-01
    • 2010-11-30
    • 2013-01-22
    • 2011-10-25
    • 2011-02-15
    相关资源
    最近更新 更多