Intuitrading

CCI 0Trend Strategy (by Marcoweb) v1.0

115
Hi guys,

I am trying to create a strategy that consists in the crossover/under of the 0 line of the Commodity Channel Index. Every time the price crosses over the 0 line in the CCI the strategy has to long getting short on the cross under and viceversa.

I have published here another script strategy (consists in a crossover/under of the Overbought/Oversold levels of the CCI) that works so I could have the opportunity to share with you the main idea that as per now is mistaken:

//@version=2
strategy(title="CCI 0Trend Strategy (by Marcoweb) v1.0", shorttitle="CCI_0T_Stra_v1.0", overlay=true)

///////////// CCI
length = input(20, minval=1)
src = input(close, title="Source")
ma = sma(src, length)
cci = (src - ma) / (0.015 * dev(src, length))
plot(cci, color=black)
band1 = hline(100, color=blue, linestyle=solid)
band0 = hline(-100, color=red, linestyle=solid)
bandl = hline(0, color=orange, linestyle=solid)
fill(band1, band0, color=olive)

p1 = plot(band0, color=red,title="-100")
p2 = plot(band1, color=blue,title="100")
p3 = plot(bandl, color=orange,title="0")

///////////// CCI 0Trend Strategy (by Marcoweb) v1.0 Strategy
if (not na(cci))

if (crossover(cci, bandl)
strategy.entry("CCI_L", strategy.long, stop=bandl, oca_type=strategy.oca.cancel, comment="CCI_L")
else
strategy.cancel(id="CCI_L")

if (crossunder(cci, bandl)
strategy.entry("CCI_S", strategy.short, stop=bandl, oca_type=strategy.oca.cancel, comment="CCI_S")
else
strategy.cancel(id="CCI_S")

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)

With this coding I get the error : line 24 (if (crossover(cci, bandl): mismatched input '|E|' expecting RPAR

Hope you like the idea ;)

オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。

チャートでこのスクリプトを利用したいですか?