AO マルチレイヤー定量トレンド強化戦略

AO EMA WF WA
作成日: 2024-12-05 15:01:48 最終変更日: 2024-12-05 15:01:48
コピー: 3 クリック数: 402
1
フォロー
1617
フォロワー

AO マルチレイヤー定量トレンド強化戦略

概要

この戦略は,動力とトレンド追跡に基づく多層の取引システムである.これは,ウィリアムズ魚指数,ウィリアムズ分形,神奇な揺れ指数 (AO) と指数移動平均 (EMA) を組み合わせて,高確率の複数の取引機会を識別する.この戦略は,トレンドが強くなると段階的にポジションを上げ,最大5つのポジションを同時に保持し,各ポジションは10%の資金を使用する.

戦略原則

戦略は,取引方向の正確性を確保するために複数のフィルタリング機構を使用する. まず,EMAを通じて長期のトレンド判断を行い,価格がEMA上にある場合にのみ多取引の機会を探します. 次に,ウィリアムズ魚指数と分形の組み合わせによって短期のトレンドを判断し,上部の分形突破が魚歯線の上にあるときに,上昇傾向が確認されます. 最後に,トレンドが確認された後,戦略は,AO指数の”ボウル形”多入りの信号を特定のタイミングとして探します.

戦略的優位性

  1. 多層のフィルタリングメカニズムにより,偽信号の干渉を効果的に軽減する.
  2. 資金管理の科学,段階的な加仓方法
  3. トレンドフォロー機能により,大きなトレンドを捉えることができます.
  4. 固定ストップではなく,技術指標の動態でトレンドの終わりを判断します.
  5. システムには優れた構成性があり,異なる市場条件に応じてパラメータを簡単に調整できます
  6. 収益因子と平均収益が良好だった.

戦略リスク

  1. 市場が揺れ動いている中で,連続した偽信号が生じる可能性がある.
  2. トレンドが反転すると、より大きなリトレースメントが発生する可能性がある
  3. 複数のフィルタリング条件により,いくつかの取引機会が失われる可能性があります.
  4. 資金管理の面で,継続的な加減は,急激な変動の時にリスクをもたらす可能性があります.
  5. EMAパラメータの選択は,戦略のパフォーマンスに大きな影響を与える

これらのリスクを減らすために,以下のようなことをお勧めします.

  • 異なる市場環境におけるパラメータの最適化
  • 波動率のフィルターを追加する
  • 更に厳しい加減条件を設定する
  • 設定する最大撤回制限

戦略最適化の方向性

  1. ATR指標に波動率フィルタを導入する
  2. 取引量分析を追加してシグナルの信頼性を向上させる
  3. ダイナミックパラメータの自己適応メカニズムの開発
  4. トレンドが減った時に利益を得るために,停止メカニズムを完善する
  5. 市場状況認識モジュールを追加し,異なる市場環境で異なるパラメータを使用

要約する

これは合理的に設計されたトレンド追跡戦略で,複数の技術指標の配合使用によって,安全性を保証しながら,良い収益パフォーマンスを達成している.戦略の革新点は,多層のトレンド確認機構と漸進的な資金管理方法にある.いくつかの最適化が必要な場所があるが,全体的に試す価値のある取引システムである.

ストラテジーソースコード
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-04 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Skyrexio

//@version=6
//_______ <licence>
strategy(title = "MultiLayer Awesome Oscillator Saucer Strategy [Skyrexio]", 
         shorttitle = "AO Saucer", 
         overlay = true, 
         format = format.inherit, 
         pyramiding = 5, 
         calc_on_order_fills = false, 
         calc_on_every_tick = false, 
         default_qty_type = strategy.percent_of_equity, 
         default_qty_value = 10, 
         initial_capital = 10000, 
         currency = currency.NONE,  
         commission_type = strategy.commission.percent, 
         commission_value = 0.1,
         slippage = 5,
         use_bar_magnifier = true)


//_______ <constant_declarations>
var const color skyrexGreen               = color.new(#2ECD99, 0)
var const color skyrexGray                = color.new(#F2F2F2, 0)
var const color skyrexWhite               = color.new(#FFFFFF, 0)


//________<variables declarations>
var int trend                             = 0
var float upFractalLevel                  = na
var float upFractalActivationLevel        = na
var float downFractalLevel                = na
var float downFractalActivationLevel      = na
var float saucerActivationLevel           = na
bool highCrossesUpfractalLevel            = ta.crossover(high, upFractalActivationLevel)
bool lowCrossesDownFractalLevel           = ta.crossunder(low, downFractalActivationLevel)
var int signalsQtyInRow                   = 0


//_______ <inputs>
// Trading bot settings
sourceUuid               = input.string(title = "sourceUuid:", defval = "yourBotSourceUuid", group = "🤖Trading Bot Settings🤖")
secretToken              = input.string(title = "secretToken:", defval = "yourBotSecretToken", group = "🤖Trading Bot Settings🤖")


// Trading period settings
lookBackPeriodStart      = input(title = "Trade Start Date/Time", defval = timestamp('2023-01-01T00:00:00'), group = "🕐Trading Period Settings🕐")
lookBackPeriodStop       = input(title = "Trade Stop Date/Time", defval = timestamp('2025-01-01T00:00:00'), group = "🕐Trading Period Settings🕐")


// Strategy settings
EMaLength                = input.int(100, minval = 10, step = 10, title = "EMA Length", group = "📈Strategy settings📈")


//_______ <function_declarations>
//@function       Used to calculate Simple moving average for Alligator
//@param src      Sourse for smma Calculations
//@param length   Number of bars to calculate smma
//@returns        The calculated smma value 
smma(src, length) =>
    var float smma = na
    sma_value = ta.sma(src, length)
    smma := na(smma) ? sma_value : (smma * (length - 1) + src) / length
    smma

//_______ <calculations>


//Upfractal calculation 
upFractalPrice = ta.pivothigh(2, 2)
upFractal = not na(upFractalPrice) 


//Downfractal calculation 
downFractalPrice = ta.pivotlow(2, 2)
downFractal = not na(downFractalPrice)


//Calculating Alligator's teeth 
teeth = smma(hl2, 8)[5]


//Calculating upfractal and downfractal levels
if upFractal 
    upFractalLevel := upFractalPrice
else
    upFractalLevel := upFractalLevel[1]


if downFractal
    downFractalLevel := downFractalPrice
else
    downFractalLevel := downFractalLevel[1]


//Calculating upfractal activation level, downfractal activation level to approximate the trend and this current trend 
if upFractalLevel > teeth
    upFractalActivationLevel := upFractalLevel

if highCrossesUpfractalLevel
    trend := 1
    upFractalActivationLevel := na 
    downFractalActivationLevel := downFractalLevel


if downFractalLevel < teeth
    downFractalActivationLevel := downFractalLevel

if lowCrossesDownFractalLevel
    trend := -1
    downFractalActivationLevel := na 
    upFractalActivationLevel := upFractalLevel


if trend == 1
    upFractalActivationLevel := na

if trend == -1
    downFractalActivationLevel := na


//Calculating filter EMA 
filterEMA = ta.ema(close, EMaLength)


//Сalculating AO saucer signal
ao = ta.sma(hl2,5) - ta.sma(hl2,34)
diff = ao - ao[1]
saucerSignal = ao > ao[1] and ao[1] < ao[2] and ao > 0 and ao[1] > 0 and ao[2] > 0 and trend == 1 and close > filterEMA


//Calculating sauser activation level
if saucerSignal
    saucerActivationLevel := high    
else 
    saucerActivationLevel := saucerActivationLevel[1]


if not na(saucerActivationLevel[1]) and high < saucerActivationLevel[1] and diff > 0
    saucerActivationLevel := high
    saucerSignal := true
    

if (high > saucerActivationLevel[1] and not na(saucerActivationLevel)) or diff < 0
    saucerActivationLevel := na 


//Calculating number of valid saucer signal in current trading cycle 
if saucerSignal and not saucerSignal[1]
    signalsQtyInRow := signalsQtyInRow + 1


if not na(saucerActivationLevel[1]) and diff < 0 and na(saucerActivationLevel) and not (strategy.opentrades[1] <= strategy.opentrades - 1)
    signalsQtyInRow := signalsQtyInRow - 1


if trend == -1 and trend[1] == 1 
    signalsQtyInRow := 0


//_______ <strategy_calls>
//Defining trade close condition
closeCondition =  trend[1] == 1 and trend == -1


//Cancel stop buy order if current Awesome oscillator column lower, than prevoius 
if diff < 0 
    strategy.cancel_all()

//Strategy entry
if (signalsQtyInRow == 1 and not na(saucerActivationLevel)) 
    strategy.entry(id = "entry1", direction = strategy.long, stop = saucerActivationLevel + syminfo.mintick,  alert_message = '{\n"base": "' + syminfo.basecurrency + '",\n"quote": "' + syminfo.currency + '",\n"position": "entry1",\n"price": "' + str.tostring(close) + '",\n"sourceUuid": "' + sourceUuid + '",\n"secretToken": "' + secretToken + '",\n"timestamp": "' + str.tostring(timenow) + '"\n}')

if (signalsQtyInRow == 2 and not na(saucerActivationLevel)) 
    strategy.entry(id = "entry2", direction = strategy.long, stop = saucerActivationLevel + syminfo.mintick,  alert_message = '{\n"base": "' + syminfo.basecurrency + '",\n"quote": "' + syminfo.currency + '",\n"position": "entry2",\n"price": "' + str.tostring(close) + '",\n"sourceUuid": "' + sourceUuid + '",\n"secretToken": "' + secretToken + '",\n"timestamp": "' + str.tostring(timenow) + '"\n}')

if (signalsQtyInRow == 3 and not na(saucerActivationLevel)) 
    strategy.entry(id = "entry3", direction = strategy.long, stop = saucerActivationLevel + syminfo.mintick,  alert_message = '{\n"base": "' + syminfo.basecurrency + '",\n"quote": "' + syminfo.currency + '",\n"position": "entry3",\n"price": "' + str.tostring(close) + '",\n"sourceUuid": "' + sourceUuid + '",\n"secretToken": "' + secretToken + '",\n"timestamp": "' + str.tostring(timenow) + '"\n}')

if (signalsQtyInRow == 4 and not na(saucerActivationLevel)) 
    strategy.entry(id = "entry4", direction = strategy.long, stop = saucerActivationLevel + syminfo.mintick,  alert_message = '{\n"base": "' + syminfo.basecurrency + '",\n"quote": "' + syminfo.currency + '",\n"position": "entry4",\n"price": "' + str.tostring(close) + '",\n"sourceUuid": "' + sourceUuid + '",\n"secretToken": "' + secretToken + '",\n"timestamp": "' + str.tostring(timenow) + '"\n}')

if (signalsQtyInRow == 5 and not na(saucerActivationLevel)) 
    strategy.entry(id = "entry5", direction = strategy.long, stop = saucerActivationLevel + syminfo.mintick,  alert_message = '{\n"base": "' + syminfo.basecurrency + '",\n"quote": "' + syminfo.currency + '",\n"position": "entry5",\n"price": "' + str.tostring(close) + '",\n"sourceUuid": "' + sourceUuid + '",\n"secretToken": "' + secretToken + '",\n"timestamp": "' + str.tostring(timenow) + '"\n}')

//Strategy exit 
if (closeCondition)
    strategy.close_all(alert_message = '{\n"base": "' + syminfo.basecurrency + '",\n"quote": "' + syminfo.currency + '",\n"position": "close",\n"price": "' + str.tostring(close) + '",\n"sourceUuid": "' + sourceUuid + '",\n"secretToken": "' + secretToken + '",\n"timestamp": "' + str.tostring(timenow) + '"\n}')


//_______ <visuals>
//Plotting shapes for adding to current long trades
gradPercent = if strategy.opentrades == 2
    90
else if strategy.opentrades == 3
    80
else if strategy.opentrades == 4
    70
else if strategy.opentrades == 5
    60

pricePlot = plot(close, title="Price", color=color.new(color.blue, 100))
teethPlot = plot(strategy.opentrades > 1 ? teeth : na, title="Teeth", color= skyrexGreen, style=plot.style_linebr, linewidth = 2)
fill(pricePlot, teethPlot, color = color.new(skyrexGreen, gradPercent))
if strategy.opentrades != 1 and  strategy.opentrades[1] == strategy.opentrades - 1
    label.new(bar_index, teeth, style = label.style_label_up, color = color.lime, size = size.tiny, text="Buy More", textcolor = color.black, text_formatting = text.format_bold)


//_______ <alerts>