
この戦略は,2つの異なる周期の移動平均の交差を利用して取引し,トレンド追跡型の戦略である.戦略は,短期および長期の移動平均の交差で購入シグナルと販売シグナルを利用して,トレンドの動きの中で取引する.
この戦略は9周期の短期移動平均SMAと50周期の長期移動平均LMAを使用する.短期移動平均が下から長期移動平均を横切ると買入シグナルが生じ,短期移動平均が上から下から長期移動平均を横切ると売出シグナルが生じます.
同時に,戦略は,RSI指標がトレンドの強さを判断することを導入した.RSIが設定された値 (>デフォルト55) よりも大きい場合にのみ,取引シグナルが生成されます.これは,RSIが超売り範囲にあるときに誤ったシグナルを生成することを防ぐことができます.
戦略 取引毎の資金は,総資金の30%を占め,取引費用の0.1%を考慮して,注文を1回だけ開きます.
利得の機会を判断するためのパラメータの最適化,他の指標の組み合わせ,厳格な資金管理,ストップ・ロスの設定によってリスクを軽減できます.
この戦略は,単純な移動平均の交差システムによってトレンドの機会を捉えます. 標準パラメータは最適化され,収益は安定し,自動取引に適しています. 他の補助指標,最適化パラメータ,停止の改善を導入することにより,戦略の安定性と収益率をさらに向上させることができます.
/*backtest
start: 2023-09-16 00:00:00
end: 2023-10-16 00:00:00
period: 2h
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/
// © relevantLeader16058
//@version=4
strategy(shorttitle='Maximized Moving Average Crossing ',title='Maximized Moving Average Crossing (by Coinrule)', overlay=true, initial_capital=1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1)
//Backtest dates
fromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12)
fromDay = input(defval = 1, title = "From Day", type = input.integer, minval = 1, maxval = 31)
fromYear = input(defval = 2020, title = "From Year", type = input.integer, minval = 1970)
thruMonth = input(defval = 1, title = "Thru Month", type = input.integer, minval = 1, maxval = 12)
thruDay = input(defval = 1, title = "Thru Day", type = input.integer, minval = 1, maxval = 31)
thruYear = input(defval = 2112, title = "Thru Year", type = input.integer, minval = 1970)
showDate = input(defval = true, title = "Show Date Range", type = input.bool)
start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start window
finish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish window
window() => time >= start and time <= finish ? true : false // create function "within window of time"
//MA inputs and calculations
inlong=input(50, title='MA long period')
inshort=input(9, title='MA short period')
MAlong = sma(close, inlong)
MAshort= sma(close, inshort)
// RSI inputs and calculations
lengthRSI = (14)
RSI = rsi(close, lengthRSI)
RSI_Signal = input(55, title = 'RSI Trigger', minval=1)
//Entry and Exit
bullish = crossover(MAshort, MAlong)
bearish = crossunder(MAshort, MAlong)
strategy.entry(id="long", long = true, when = bullish and RSI > RSI_Signal and window())
strategy.close(id="long", when = bearish and window())
plot(MAshort, color=color.purple, linewidth=2)
plot(MAlong, color=color.red, linewidth=2)