交易视图 - 如何设置百分比佣金?



如何在Pine脚本中设置策略.佣金.百分比?

我知道如何在手动设置中将佣金设置为百分比。但是有没有办法用代码设置佣金?

这是我的策略脚本:

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")

我在这里找到了如何做到这一点:

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

最新更新