AO 다층 양적 추세 강화 전략

AO EMA WF WA
생성 날짜: 2024-12-05 15:01:48 마지막으로 수정됨: 2024-12-05 15:01:48
복사: 3 클릭수: 402
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

AO 다층 양적 추세 강화 전략

개요

이 전략은 동력과 트렌드 추적에 기반한 다단계 거래 시스템이다. 그것은 윌리엄스어 지표, 윌리엄스 분화 지표, 마법의 흔들림 지표 ((AO) 와 지수 이동 평균 ((EMA) 를 결합하여 높은 확률의 여러 기회를 식별한다. 전략은 자본의 계층적 투입 메커니즘을 채택하고, 추세가 강화될 때 단계적으로 포즈를 올리고, 최대 5개의 포지션을 동시에 보유할 수 있으며, 각 포지션은 10%의 자금을 사용한다.

전략 원칙

전략은 거래 방향의 정확성을 보장하기 위해 여러 가지 필터링 메커니즘을 사용한다. 첫째, EMA를 통해 장기적인 트렌드 판단을 하고, 가격이 EMA 위에 있을 때만 더 많은 기회를 찾는다. 둘째, 윌리엄스 갈매기 지표와 분형의 조합을 통해 단기적인 트렌드를 판단하고, 상위 분형의 돌파구가 갈매기 치아선 위에 있을 때, 상승 트렌드가 확립된다. 마지막으로, 트렌드를 확인한 후, 전략은 AO 지표의 “배구형” 다중 신호를 찾아 구체적인 시점으로 들어간다. 시스템은 매 포지션에 10%의 자금을 사용하며, 추세가 지속될 때 최대 5개의 더 많은 포지션을 열 수 있다.

전략적 이점

  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>