代码之家  ›  专栏  ›  技术社区  ›  whitesiroi

TradingView-如何以百分比设置佣金?

  •  2
  • whitesiroi  · 技术社区  · 6 年前

    我怎么设置 strategy.commission.percent 用松木写的?

    我知道如何在手动设置中将佣金设置为百分比。但是有没有一种方法可以用代码来设置佣金呢?

    这是我的策略脚本:

    strategy("Working 55 & 200 EMA strategy", overlay = true, initial_capital=1000)
    
    fast = input(defval = 55, step = 5)
    slow = input(200)
    
    ma1 = ema(close, fast)
    ma2 = ema(close, slow)
    
    plot(ma1, title = "Fast MA", color = lime, style = line, linewidth = 3)
    plot(ma2, title = "Slow MA", color = black, style = line, linewidth = 3)
    
    // === INPUT BACKTEST RANGE ===
    FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
    FromDay   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
    FromYear  = input(defval = 2018, title = "From Year", minval = 2010)
    ToMonth   = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
    ToDay     = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
    ToYear    = input(defval = 9999, title = "To Year", minval = 2017)
    
    // === FUNCTION EXAMPLE ===
    start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)  // backtest start window
    finish    = timestamp(ToYear, ToMonth, ToDay, 23, 59)        // backtest finish window
    window()  => time >= start and time <= finish ? true : false // create function "within window of time"
    
    strategy.entry("Buy", strategy.long, when = window() and crossover(ma1, ma2))
    strategy.entry("Sell", strategy.short, when = window() and crossover(ma2, ma1))
    strategy.exit("Buy")
    strategy.exit("Sell")
    
    1 回复  |  直到 6 年前
        1
  •  2
  •   Jos    6 年前

    我知道怎么做了 here :

    strategy("Working 55 & 200 EMA strategy", overlay=true, 
         initial_capital=1000, 
         commission_type=strategy.commission.percent, 
         commission_value=0.2)
    
    推荐文章