【问题标题】:Strategy entry not getting execute despite condition being fulfilled尽管条件已满足,但策略条目未执行
【发布时间】:2021-01-06 03:43:19
【问题描述】:
strategy("Custom_ema_strategy", overlay=true , shorttitle="Custom EMA Strategy" ,initial_capital=10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100.00, commission_type="percent", commission_value=0.00)

//Inputs
fastMALength = input(title = "Fast MA Length" , type = input.integer , defval = 10)
slowMALength = input(title = "Slow MA Length" , type = input.integer , defval = 20)
selectSource = input(title = "Source" , type = input.source , defval = close)
fastMA = ema(selectSource , fastMALength)
slowMA = ema(selectSource , slowMALength)
filter = input(title = 'Filter' , type = input.integer , defval = 50)

plot(fastMA , color = color.yellow , linewidth = 2 , title = 'FAST MA')
plot(slowMA , color = color.blue , linewidth = 2 , title = 'SLOW MA')
plot(low , title='Title', color=#00ffaa, linewidth=2, style=plot.style_circles)

longCondition = low > fastMA and low > slowMA
shortCondition = crossunder(fastMA , slowMA)

plotchar(longCondition , 'longCondition' , '')
plotchar(low , 'low' , '')
plotchar(fastMA , 'fastMA' , '')


if longCondition
    strategy.entry("Long Entry", long = strategy.long)

一个。上面的策略没有被执行,因为我的 longCondition 是直截了当的,我只需要低于 fastMA 和 slowMA 的低点。如您所见,突出显示的蜡烛满足条件但未执行。不太清楚为什么它不执行。

b.这个蓝色突出显示的蜡烛应该失败,因为低点是 6551.00,而 slowMA 是 6551.49,这应该是假的,因为条件是 low > slowMA 但 longCondition 是 1.00,它返回 true。

c。突出显示的部分显示条件何时满足,如何在满足条件后的下一根蜡烛(箭头指示)处输入策略。

【问题讨论】:

    标签: pine-script algorithmic-trading


    【解决方案1】:

    您在数据集中早期获得了一个条目,但由于您没有退出交易,您获得的条目数量将对应于您允许的金字塔条目数量:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-17
      • 1970-01-01
      相关资源
      最近更新 更多