高低点移動平均値に基づく定量的な取引戦略

作者: リン・ハーンチャオチャン開催日:2023年9月19日 15:53:55
タグ:

概要

この戦略は,現在の閉値と比較して高値と低値の単純な移動平均を使用してエントリーと出口を決定します.初期のトレンド機会を得るために移動平均クロスオーバーからの価格ブレイクシグナルを捕捉することを目的としています.

戦略の論理

  1. 高値の4期間の単純な移動平均を計算する.

  2. 低価格の4期間の単純な移動平均を計算する.

  3. 閉じる価格が高点SMAを突破するとロングする.

  4. 閉じる価格が低点SMAを下回るとショートします

  5. リスク管理のために固定ストップロスを利用し 利益を取ります

利点分析

  1. シンプルな指標を使い 分かりやすく実行します

  2. タイムリーで SMAのクロスオーバーからの価格ブレイク信号を捕捉します

  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)






    

もっと