
これは,双均線に基づく簡単な日内取引戦略である.これは,2つの異なる周期の簡単な移動平均線を使用し,均線が交差する時に買ったり売ったりする.信号が変化するときに,倍数の平仓を使用し,逆にポジションを開く.当日の内取引時間の終わりに,ポジションがまだ平仓していない場合は,全平仓である.
この戦略は,10日と40日の2つの簡単な移動平均線を使用する.短期平均線が長期平均線を穿越するとき,多めに行い;短期平均線が長期平均線を穿越するとき,空いて行い.信号が変化したとき,倍数ハンドを使用して平仓を入れ,その後逆向きにポジションを開く.定義された日内取引時間内に,平線信号に従って取引する.当日の取引時間終了時に,まだ平準されていないポジションがあれば,全部平仓する.
この戦略は主に短期平均線が価格変化をより早く捕捉する特性を利用している.短期平均線上を穿越すると,短期価格が上昇し始めると,このトレンドを捕捉することができる.短期平均線下を穿越すると,短期価格が低下し始めると,空白でこのトレンドを捕捉することができる.倍数逆の開設ポジションの設計は,ポジションを拡大し,利益の余地を拡大することができる.
リスクに対する対処法:
平均線パラメータを最適化します.より多くの組み合わせをテストして,最適なパラメータを探します.
他の技術指標のフィルタを追加する.例えば,MACD指標の確認を加えることで,誤信号率を下げる.
ポジション開設の逆倍数を最適化する.異なる倍数サイズをテストし,最適なパラメータを見つける.
異なる日中の取引時間をテストする. 適切な延長時間は,よりよいリターンを得ることができる.
この戦略の全体的な構想は単純で,双均線交差の形成による短期トレンドを捕捉し,二倍手数逆転開設により利益の余地を拡大し,最後に,日中の時段取引により夜間のリスクを回避する.これは,日中のショートライン取引に適した効果的な戦略である.パラメータを調整し,その他の技術指標のフィルターを追加することで,さらなる最適化の余地があり,よりよい戦略効果を得ることができる.
/*backtest
start: 2024-02-19 00:00:00
end: 2024-02-26 00:00:00
period: 1m
basePeriod: 1m
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/
// © Pritesh-StocksDeveloper
//@version=4
strategy("Moving Average - Intraday", shorttitle = "MA - Intraday",
overlay=true, calc_on_every_tick = true)
// Used for intraday handling
// Session value should be from market start to the time you want to square-off
// your intraday strategy
var i_marketSession = input(title="Market session", type=input.session,
defval="0915-1455", confirm=true)
// Short & Long moving avg. period
var int i_shortPeriod = input(title = "Short MA Period", type = input.integer,
defval = 10, minval = 2, maxval = 20, confirm=true)
var int i_longPeriod = input(title = "Long MA Period", type = input.integer,
defval = 40, minval = 3, maxval = 120, confirm=true)
// A function to check whether the bar is in intraday session
barInSession(sess) => time(timeframe.period, sess) != 0
// Calculate moving averages
shortAvg = sma(close, i_shortPeriod)
longAvg = sma(close, i_longPeriod)
// Plot moving averages
plot(series = shortAvg, color = color.red, title = "Short MA",
linewidth = 2)
plot(series = longAvg, color = color.blue, title = "Long MA",
linewidth = 2)
// Long/short condition
longCondition = crossover(shortAvg, longAvg)
shortCondition = crossunder(shortAvg, longAvg)
// See if intraday session is active
bool intradaySession = barInSession(i_marketSession)
// Trade only if intraday session is active
// Long position
strategy.entry(id = "Long", long = strategy.long,
when = longCondition and intradaySession)
// Short position
strategy.entry(id = "Short", long = strategy.short,
when = shortCondition and intradaySession)
// Square-off position (when session is over and position is open)
squareOff = (not intradaySession) and (strategy.position_size != 0)
strategy.close_all(when = squareOff, comment = "Square-off")