尽管满足条件,但策略条目未执行

Strategy entry not getting execute despite condition being fulfilled

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,这应该是错误的,因为条件是低 > slowMA 但 longCondition 是 1.00,returns true。

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

您在您的数据集中早期获得了一个入场点,但因为您没有退出交易,所以您获得的入场点数量将对应于您允许的金字塔入场点数量: