高値と安値の移動平均に基づく定量取引戦略


作成日: 2023-09-19 15:53:55 最終変更日: 2023-09-19 15:53:55
コピー: 0 クリック数: 626
1
フォロー
1617
フォロワー

概要

この戦略は,高点と低点の単純な移動平均を計算し,現在の閉盘価格と対比して買いと売却のタイミングを判断する.その目的は,価格が平均線を突破するシグナルを捕捉して,トレンドの早期のチャンスを得ることである.

戦略原則

  1. 平均移動は,平均移動は,平均移動は,平均移動は,

  2. 平均移動は,平均移動は,平均移動は,平均移動は,

  3. 閉盤が高点平均線を突破すると,追加入場を行う

  4. 閉店価格が低点平均線を突破したときに空白入場

  5. 固定ストップとストップストップ戦略を用いたリスク管理

優位分析

  1. シンプルで分かりやすい指標を用いて実現

  2. 価格が平均線を突破する信号を捕捉する

  3. 音の部分を素早くフィルターし,トレンドを認識します.

  4. 戦略の運用コストを削減する計算量

  5. 拡大のための適性に基づく戦略

リスク分析

  1. 合理的なパラメータを設定し,過度に敏感にならないようにする.

  2. 大規模な突破の危険に 対処できない

  3. リスクは,ある程度あります.

  4. 自動で停止停止位置を調整できない

  5. トレンドの背景の長さは判り難い

最適化の方向

  1. 異なるパラメータが信号品質に与える影響をテストする

  2. 突破の有効性を保証するフィルタリング条件を追加する

  3. トレンド分析を組み合わせて,騙されないようにする

  4. ダイナミック・ストップ・ストップ・ストラトジーを開発する

  5. 戦略の勝利率を向上させる

  6. 異なるサイクルで戦略の強さをテストする

要約する

この戦略は,簡単な指標を研究して価格動力を判断し,基本的トレンド取引の考えを与えます.パラメータ最適化,リスク管理などと連携してさらに完善され,取引ロジックは拡張性があり,比較的安定した量化システムに発展できます.全体的に,この戦略は,操作が簡単で,量化取引の入門戦略として適しています.

ストラテジーソースコード
/*backtest
start: 2023-09-11 00:00:00
end: 2023-09-13 00:00:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("HiLo", overlay=true)

// Testing a specific period
testStartYear = input(2017, "Backtest Start Year")
testStartMonth = input(4, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)

testStopYear = input(2017, "Backtest Stop Year")
testStopMonth = input(5, "Backtest Stop Month")
testStopDay = input(1, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)

// A switch to control background coloring of the test period
testPeriodBackground = input(title="Color Background?", type=bool, defval=true)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FF00 : na
bgcolor(testPeriodBackgroundColor, transp=97)

testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false


//HiLo Strategy
length = input(4, minval=0)
displace = input(0, minval=0)
highsma = sma(high, length)
lowsma = sma(low, length)

longCondition = close > highsma[displace]
if (longCondition)
    strategy.entry("long", true)

shortCondition = close < lowsma[displace]
if (shortCondition)
    strategy.entry("short", false)

// Exit seems with a problem. it keeps saying the order's limit (2000) was reached even if I back test it just for a day. 
// If the two lines bellow are commented, then it it works. Anyone? Any idea what's wrong?

// strategy.exit("exit", "long", profit=10, loss=5)
// strategy.exit("exit", "short", profit=10, loss=5)