Pine script 策略不会进入交易

Pine script 策略不会进入交易,pine-script,algorithmic-trading,back-testing,Pine Script,Algorithmic Trading,Back Testing,我的代码没有显示任何错误,但当我尝试启动它时,没有给出任何条目,除此之外,我想添加两个额外的过滤器: RSI>50(做多时) SlowEMA>SMA(长时间运行时) Close>SlowEMA(做多时) 有什么建议吗 FastEMA = ema(close,9) // EMA Fast 9 periods plot(FastEMA,color=color.fuchsia) SlowEMA = ema(close,26) // EMA Slow 26 periods plot(SlowEMA,

我的代码没有显示任何错误,但当我尝试启动它时,没有给出任何条目,除此之外,我想添加两个额外的过滤器:

  • RSI>50(做多时)
  • SlowEMA>SMA(长时间运行时)
  • Close>SlowEMA(做多时)
有什么建议吗

FastEMA = ema(close,9) // EMA Fast 9 periods
plot(FastEMA,color=color.fuchsia)
SlowEMA = ema(close,26) // EMA Slow 26 periods
plot(SlowEMA,color=color.blue)
plot(sma(close,200),color=color.gray) // SMA 200 periods
rsi = rsi(close, 14) // Relative strength index

// Donchian Channel

length = input(20, minval=1) 
lower = lowest(length)
upper = highest(length)
basis = avg(upper, lower)
u = plot(upper, "Upper", color=#FF9400)
l = plot(lower, "Lower", color=#FF9400)

// Specify crossover conditions

longCondition = crossover(FastEMA, SlowEMA)
shortCondition = crossunder(FastEMA, SlowEMA)

// Execution

if (longCondition)
    strategy.entry("long", strategy.long, 100)

您还必须添加一个退出该职位的函数,如strategy.order、stragegy.close或strategy.exit

举个例子,如果你在进入交易后退出5个酒吧,你可以选择

if (barssince(change(strategy.opentrades)) == 5)
    strategy.close("long", comment = "timeout")  

您还必须添加一个退出该职位的函数,如strategy.order、stragegy.close或strategy.exit

举个例子,如果你在进入交易后退出5个酒吧,你可以选择

if (barssince(change(strategy.opentrades)) == 5)
    strategy.close("long", comment = "timeout")  

您可以尝试将
绘图(longCondition?1:0)
添加到脚本中,看看当绘图的值为
1
时是否有一些条形图。可能条件总是错误的。好主意,谢谢@andreyd您可以尝试将
绘图(longCondition?1:0)
添加到脚本中,当绘图的值为
1
时会出现一些条形图。也许条件总是错误的。好主意,谢谢@andreyd这就是我错过的,非常感谢!这就是我错过的,非常感谢!