Estratégia de Scalping do Alligador de Williams

Autora:ChaoZhang, Data: 2023-09-25 17:42:27
Tags:

Resumo

Esta estratégia é baseada no indicador Bill Williams Alligator, mas usa velas Heiken Ashi como entrada de preço.

Estratégia lógica

Os principais princípios de negociação da estratégia são:

  1. Usando velas Heiken Ashi em vez de velas normais para a ação do preço.

  2. Aplicando as três linhas de média móvel do Bill Williams Alligator - Maxilar, Dentes e Lábios.

  3. Quando as linhas são empilhadas como Jaw (mais baixo), Teeth (meio), Lips (mais alto), sinaliza uma tendência de alta.

  4. As entradas são baseadas na direção da vela Heiken Ashi + alinhamento da linha do jacaré.

  5. Sai quando as linhas do Alligator se cruzam, sinalizando a reversão da tendência.

  6. Pontos fixos de take profit, stop loss utilizados para gestão de riscos. Pode configurar pontos alvo, pontos stop loss, trailing stops etc.

Combinar filtros duplos de Heiken Ashi e Alligator cria uma estratégia de negociação de curto prazo de alta probabilidade.

Vantagens

As principais vantagens da estratégia são:

  1. Filtragem de indicadores duplos minimiza sinais falsos.

  2. Identificação de tendências clara e intuitiva.

  3. Eficiente para scalping de curto prazo, captura oscilações de preços em gráficos de 1 a 5 minutos.

  4. Parâmetros simples, sem necessidade de otimização complexa.

  5. Gestão rigorosa de riscos através de pontos de lucro e stop loss.

  6. Regras definidas de entrada/saída baseadas em cruzes de linhas de Alligator.

  7. Fácil de implementar e replicar.

Riscos

Os principais riscos a considerar são:

  1. Os sinais frequentes do Alligator podem aumentar os negócios e os custos.

  2. Risco de mercado limitado, os crossovers falham em condições agitadas.

  3. Risco de otimização excessiva, ajustamento da curva por mau ajuste dos parâmetros.

  4. Risco de falha do indicador, o jacaré pode parar de funcionar em condições extremas.

  5. Risco de deslizamento de stop loss, as lacunas podem desencadear stop causando perdas injustificadas.

  6. Riscos de alta frequência de negociação: mais negociações também aumentam os custos de transacção.

A análise das expectativas, as paradas otimizadas, a frequência controlada, etc., podem abordar muitos destes riscos.

Oportunidades de melhoria

Algumas formas de melhorar a estratégia são:

  1. Incorporar filtros adicionais como RSI para maior taxa de vitória.

  2. Usar paradas ATR dinâmicas para controlar as perdas por transação.

  3. Adicione regras de dimensionamento de posições para otimizar o tamanho da aposta.

  4. Combinar padrões gráficos ou outras análises técnicas para o calendário de entrada.

  5. Otimizar os parâmetros com base no tipo de instrumento (ações, divisas, etc.).

  6. Introduzir aprendizado de máquina para otimização de parâmetros adaptativos.

  7. Realizar análises de expectativas para ajustar os rácios de lucro e perda.

Com melhorias contínuas, a estratégia pode tornar-se um robusto sistema de negociação a curto prazo.

Conclusão

A estratégia combina Heiken Ashi com Williams Alligator para criar uma estratégia de negociação de curto prazo de alta probabilidade. Ela se beneficia de filtragem de indicadores duplos, parâmetros diretos e mecânica de entrada / saída bem definida para efetivamente reduzir as tendências e reversões.


/*backtest
start: 2022-09-18 00:00:00
end: 2023-09-24 00:00:00
period: 4d
basePeriod: 1d
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/
// © 03.freeman
//Scalping strategy based on Bill Williams Alligator technique but applied to heikin ashi candles
//This strategy has to be applied to standard candles and low time frames (1min to 5min)
//@version=4
strategy("Bill Williams Alligator improved", shorttitle="Scalping alligator",overlay=true)
//source = input(close)
useHA = input (true,"Use heikin ashi candle?")

// ----------MA calculation - ChartArt-------------
smoothinput = input(1, minval=1, maxval=5, title='Moving Average Calculation: (1=SMA), (2=EMA), (3=WMA), (4=Linear), (5=VWMA)')

calc_ma(src,l) => 
    smoothinput == 1 ? sma(src, l):smoothinput == 2 ? ema(src, l):smoothinput == 3 ? wma(src, l):smoothinput == 4 ? linreg(src, l,0):smoothinput == 5 ? vwma(src,l):na
//----------------------------------------------

heikinashi_close = security(heikinashi(syminfo.tickerid), timeframe.period, close)
heikinashi_open = security(heikinashi(syminfo.tickerid), timeframe.period, open)
heikinashi_hl2 = security(heikinashi(syminfo.tickerid), timeframe.period, hl2)

direzione=heikinashi_close>heikinashi_open and heikinashi_close[1]>heikinashi_open[1]? 1 : heikinashi_close<heikinashi_open and heikinashi_close[1]<heikinashi_open[1]? -1 : 0

jawLength = input(13, minval=1, title="Jaw Length")
teethLength = input(8, minval=1, title="Teeth Length")
lipsLength = input(5, minval=1, title="Lips Length")
jawOffset = input(8, title="Jaw Offset")
teethOffset = input(5, title="Teeth Offset")
lipsOffset = input(3, title="Lips Offset")
jaw = calc_ma(heikinashi_hl2, jawLength)
teeth = calc_ma(heikinashi_hl2, teethLength)
lips = calc_ma(heikinashi_hl2, lipsLength)
plot(jaw, title="jaw",offset = jawOffset, color=#3BB3E4)
plot(teeth, title="teeth",offset = teethOffset, color=#FF006E)
plot(lips, title="lips",offset = lipsOffset, color=#36C711)

longCondition = direzione[0]==1 and jaw<teeth and jaw<lips and teeth<lips 
shortCondition = direzione[0]==-1 and jaw>teeth and jaw>lips and teeth>lips


//  Strategy: (Thanks to JayRogers)
// === STRATEGY RELATED INPUTS ===
//tradeInvert     = input(defval = false, title = "Invert Trade Direction?")
// the risk management inputs
inpTakeProfit   = input(defval = 0, title = "Take Profit Points", minval = 0)
inpStopLoss     = input(defval = 0, title = "Stop Loss Points", minval = 0)
inpTrailStop    = input(defval = 0, title = "Trailing Stop Loss Points", minval = 0)
inpTrailOffset  = input(defval = 0, title = "Trailing Stop Loss Offset Points", minval = 0)

// === RISK MANAGEMENT VALUE PREP ===
// if an input is less than 1, assuming not wanted so we assign 'na' value to disable it.
useTakeProfit   = inpTakeProfit  >= 1 ? inpTakeProfit  : na
useStopLoss     = inpStopLoss    >= 1 ? inpStopLoss    : na
useTrailStop    = inpTrailStop   >= 1 ? inpTrailStop   : na
useTrailOffset  = inpTrailOffset >= 1 ? inpTrailOffset : na

// === STRATEGY - LONG POSITION EXECUTION ===
enterLong() => direzione[0]==1 and jaw<teeth and jaw<lips and teeth<lips // functions can be used to wrap up and work out complex conditions
exitLong() => jaw>teeth or jaw>lips or teeth>lips
strategy.entry(id = "Buy", long = true, when = enterLong() )    // use function or simple condition to decide when to get in
strategy.close(id = "Buy", when = exitLong() )                  // ...and when to get out

// === STRATEGY - SHORT POSITION EXECUTION ===
enterShort() => direzione[0]==-1 and jaw>teeth and jaw>lips and teeth>lips
exitShort() => jaw<teeth or jaw<lips or teeth<lips
strategy.entry(id = "Sell", long = false, when = enterShort())
strategy.close(id = "Sell", when = exitShort() )

// === STRATEGY RISK MANAGEMENT EXECUTION ===
// finally, make use of all the earlier values we got prepped
strategy.exit("Exit Buy", from_entry = "Buy", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
strategy.exit("Exit Sell", from_entry = "Sell", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)

// === Backtesting Dates === thanks to Trost

testPeriodSwitch = input(false, "Custom Backtesting Dates")
testStartYear = input(2020, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testStartHour = input(0, "Backtest Start Hour")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,testStartHour,0)
testStopYear = input(2020, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(31, "Backtest Stop Day")
testStopHour = input(23, "Backtest Stop Hour")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,testStopHour,0)
testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false
isPeriod = true
// === /END

if not isPeriod
    strategy.cancel_all()
    strategy.close_all()

Mais.