この戦略は,移動平均に基づいて取引チャネルを形成し,価格がチャネルを突破して上下軌道に乗るときに取引信号を生成する.これは,パラメータの最適化により,シンプルで効果的な長短ポジションの操作を実現する典型的なトレンドフォロー戦略である.
移動平均を計算するには,SMA/EMA/WMA/RMAなどの複数のタイプを選択できます.
経路上軌道の移動平均に一定比例の増加。下軌道の一定比例の減少。
価格が上線を突破すると多做;下線を突破すると空きをする.ただ多做,空きのみ,または双方向取引の選択肢がある.
ストップ・ストップ・ロスを設定する. ストップ・ロスは入場価格の一定比率の増加である. ストップ・ロスは一定比率の減少である.
移動平均の計算はシンプルで,トレンド判断は簡単です.
調整可能なパラメータにより,異なるポジション保持時間とリスクの好みを実現します.
複数の空いた場所を選び,さまざまな市場状況に適応します.
ストップ・ストップ・損失の固定比率,制御性が強い.
傾向が変わると 騙されやすい.
パラメータの設定が不適切である場合,取引が頻繁すぎたり遅れたりすることがあります.
固定比率のストップ・ストップ・損失は柔軟性がない.
双方向取引は取引頻度や手数料のコストを増加させます.
移動平均のパラメータを最適化し,遅延とノイズをバランスする.
チャンネルの帯域を最適化し,市場の波動の周波数に対応する.
異なる止止損設定をテストする. 動的止損はより効果的です.
傾向や振動指標などの判断を高めます.
この記事の記事へのトラックバック一覧です:
この戦略は,移動平均チャネルを通じて簡単なトレンドフォローを実現しますが,パラメータ最適化とリスク制御の強化が必要です.この基礎で,より多くの技術指標を導入して,戦略の論理をさらに完善することができます.
/*backtest
start: 2023-08-17 00:00:00
end: 2023-09-16 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TaylorTneh
//@version=4
// strategy("Moving Average Band Taylor V1",shorttitle="MA Band+",overlay=true,default_qty_type=strategy.cash,default_qty_value=1000,initial_capital=1000,currency=currency.USD,commission_value=.1)
price = input(close, title="Source")
mabtype = input(title="Moving Average Type", defval="RMA", options=["SMA", "EMA", "RMA", "WMA"])
malen = input(10, "MA Period : 10")
magap = input(0.6, "Band Gap : 0.6", minval = -10, maxval = 10, step = 0.1)
mabup = if mabtype == "SMA"
sma(high, malen)
else
if mabtype == "EMA"
ema(high, malen)
else
if mabtype == "WMA"
wma(high, malen)
else
if mabtype == "RMA"
rma(high, malen)
mabdn = if mabtype == "SMA"
sma(low, malen)
else
if mabtype == "EMA"
ema(low, malen)
else
if mabtype == "WMA"
wma(low, malen)
else
if mabtype == "RMA"
rma(low, malen)
upex = mabup * (1 + magap/100)
dnex = mabdn * (1 - magap/100)
plot(upex, "Upper MA Band", color.orange)
plot(dnex, "Lower MA Band", color.orange)
//-------------------------------------------- (Strategy)
strategy.entry("Long", strategy.long, stop = upex)
strategy.entry("Short", strategy.short, stop = dnex)
//Long Only//strategy.entry("Long", strategy.long, stop = upex)
//Long Only//strategy.exit("Short", stop = dnex)
//Short Only//strategy.entry("Short", strategy.short, stop = dnex)
//Short Only//strategy.exit("Long", stop = upex)
//-------------------------------------------- (Take Profit & Stop Lose)
stopPer = input(500.0, title='# Stop Loss %', type=input.float) / 100
takePer = input(500.0, title='# Take Profit %', type=input.float) / 100
//Determine where you've entered and in what direction
longStop = strategy.position_avg_price * (1 - stopPer)
shortStop = strategy.position_avg_price * (1 + stopPer)
shortTake = strategy.position_avg_price * (1 - takePer)
longTake = strategy.position_avg_price * (1 + takePer)
if strategy.position_size > 0
strategy.exit(id="L-TP/SL", stop=longStop, limit=longTake)
if strategy.position_size < 0
strategy.exit(id="S-TP/SL", stop=shortStop, limit=shortTake)
//-------------------------------------------- (Sample Time Filter Strategy)
//fromyear = input(2018, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")
//toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
//frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
//tomonth = input(10, defval = 10, minval = 01, maxval = 12, title = "To Month")
//fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
//today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")
//strategy.entry("Long", strategy.long, stop = upex, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
//strategy.entry("Short", strategy.short, stop = dnex, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
//--------------------------------------------