【问题标题】:buy - sell conditions with EMA 200EMA 200 的买卖条件
【发布时间】:2021-08-17 06:50:12
【问题描述】:

我在策略中针对以下条件写的内容:1) 如果价格高于 200 EMA,请不要做空 2) 如果价格低于 200 EMA,请不要做多 ----- 这些条件应该写在策略的哪一点?

【问题讨论】:

    标签: pine-script


    【解决方案1】:
    strategy("200ema", overlay=true)  
    
    ema1=ema(close,1)
    ema2=ema(close,200)
    
    buy= crossover(ema1,ema2)
    sell=crossunder(ema1,ema2)
    
    if (buy)
        strategy.entry("Buy", strategy.long)
        
    if (sell)
        strategy.entry("Sell", strategy.short) 
         
    

    这是一个简单的脚本,当 ema1 与 ema2 交叉时将显示买入/卖出。

    如果你想做一些事情,比如“价格必须高于 200 才能触发买入,低于 200 才能触发卖出”

    添加这个

    strategy("200ema", overlay=true)  
    
    ema1=ema(close,1)
    ema2=ema(close,200)
    
    bf=ema1>ema2
    sf=ema1<ema2
    buy= (your strategy) and bf
    sell=(your strategy) and sf
    
    if (buy)
        strategy.entry("Buy", strategy.long)
    
    if (sell)
        strategy.entry("Sell", strategy.short) 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-06
      • 1970-01-01
      • 1970-01-01
      • 2022-07-28
      • 2017-09-26
      • 1970-01-01
      • 2021-07-28
      • 1970-01-01
      相关资源
      最近更新 更多