yuya_takahashi_

Pine講座㉜ バックテスト|BB Strategy directed の解説

تعليم
yuya_takahashi_ تم تحديثه   
FX:USDJPY   دولار أمريكي / ين ياباني
このストラテジーは、前回解説したものに

・買いのみの戦略
・売りのみの戦略
・買い売り両方の戦略

を選択できる機能を追加されたものです。

コードも2行増えるだけなので簡単ですね!

※ 追加された箇所だけ解説を入れます
=====
//@version=4
strategy("Bollinger Bands Strategy directed の解説", overlay=true)

source = close

length = input(20, minval=1)
mult = input(2.0, minval=0.001, maxval=50)

//買いのみ、売りのみ、両方を指定する設定項目
//1,0,-1で設定する
//初期値は0
direction = input(0, title = "Strategy Direction", type=input.integer, minval=-1, maxval=1)

//strategy.risk.allow_entry_in( ) で「買いのみ、売りのみ、両方」を指定
// 0 → strategy.direction.all → 両方
//-1 → strategy.direction.short → 売りのみ
// 1 → strategy.direction.long → 買いのみ
strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))

basis = sma(source, length)
dev = mult * stdev(source, length)

upper = basis + dev
lower = basis - dev

if (crossover(source, lower))
strategy.entry("BBandLE", strategy.long, stop=lower, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandLE")
else
strategy.cancel(id="BBandLE")

if (crossunder(source, upper))
strategy.entry("BBandSE", strategy.short, stop=upper, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandSE")
else
strategy.cancel(id="BBandSE")

plot( basis )
plot( upper )
plot( lower )
=====
تعليق:
次の講座

小次郎講師公式インジケーターのお申込
bit.ly/2vdSV4Q

小次郎講師のLINE@
bit.ly/2VZQFu3

小次郎講師のチャート情報局
bit.ly/2GvLAEp
إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.