转换基本的Pine脚本策略以研究创建警报

时间:2020-05-24 15:10:31

标签: pine-script algorithmic-trading

我想转换一个简单的TradingView脚本“ ChannelBreakOutStrategy”来研究脚本,有人可以帮助我吗?

实际上,我在plotshape策略和研究方面存在差异,我不明白为什么。

//@version=4
strategy("ChannelBreakOutStrategy Julien", overlay=true)
length = input(title="Length", type=input.integer, minval=1, maxval=1000, defval=5)

upBound = highest(high, length)
downBound = lowest(low, length)

if (not na(close[length]))
    strategy.entry("ChBrkLE", strategy.long, stop=upBound + syminfo.mintick, comment="Achat")
    strategy.entry("ChBrkSE", strategy.short, stop=downBound - syminfo.mintick, comment="Vente")

我必须尝试通过此简单转换进行转换,但失败:

//@version=4
study("Alert convert Julien", overlay=true)
length = input(title="Length", type=input.integer, minval=1, maxval=1000, defval=10)

upBound = highest(high, length)
downBound = lowest(low, length)

short_cond = close[length] < downBound
long_cond = close[length] > upBound

plotshape(short_cond, title="vente", style=shape.triangledown, color=color.red)
plotshape(long_cond, title="achat", style=shape.triangleup, color=color.green)

alertcondition(short_cond or long_cond, title='Vente ou achat', message='Vente ou achat - Red and blue have crossed!')

plot(close)

在屏幕快照中看到差异“ Vente” =策略,而“ Test Vente” =学习测试:

Démo

谢谢! ?

0 个答案:

没有答案