【发布时间】: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