
A estratégia de captura de tendências William Herschel equidistante é uma estratégia de acompanhamento de tendências que combina o William Herschel indicador e média móvel. A estratégia utiliza a posição relativa das três linhas do William Herschel indicador (linhas de dentes, dentes e lábios) para julgar a direção da tendência, usando a média móvel como uma segunda confirmação da tendência.
O núcleo da estratégia de captura de tendências da linha de equilíbrio William Herschel é o uso do indicador William Herschel e da média móvel para identificar e confirmar tendências. O indicador William Herschel é composto por três linhas: a linha de equilíbrio Jaws, Teeth e Lips, que são respectivamente médias móveis de deslizamento liso em diferentes períodos. Quando o mercado está em uma tendência ascendente, o lábio está acima da linha de dentes, a linha de dentes está acima da linha de equilíbrio; quando o mercado está em uma tendência descendente, o lábio está abaixo da linha de dentes e a linha de dentes está abaixo da linha de equilíbrio.
A estratégia de captura de tendências lineares William Herschel, combinando o indicador William Herschel com a média móvel, forma uma estratégia de acompanhamento de tendências simples e eficaz. A estratégia é adequada para mercados fortemente tendenciais, aumentando a precisão de identificação de tendências através de mecanismos de dupla confirmação.
/*backtest
start: 2024-05-09 00:00:00
end: 2024-05-16 00:00:00
period: 5m
basePeriod: 1m
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/
// © tradedots
//@version=5
strategy("Alligator + MA Trend Catcher [TradeDots]", overlay=true, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 80, commission_type = strategy.commission.percent, commission_value = 0.01)
// william alligator
smma(src, length) =>
smma = 0.0
smma := na(smma[1]) ? ta.sma(src, length) : (smma[1] * (length - 1) + src) / length
smma
jawLength = input.int(8, minval=1, title="Jaw Length", group = "william alligator settings")
teethLength = input.int(5, minval=1, title="Teeth Length", group = "william alligator settings")
lipsLength = input.int(3, minval=1, title="Lips Length", group = "william alligator settings")
jawOffset = input(8, title="Jaw Offset", group = "william alligator settings")
teethOffset = input(5, title="Teeth Offset", group = "william alligator settings")
lipsOffset = input(3, title="Lips Offset", group = "william alligator settings")
jaw = smma(hl2, jawLength)
teeth = smma(hl2, teethLength)
lips = smma(hl2, lipsLength)
// ma
input_trendline_length = input.int(200, "Trendline Length", group = "moving average settings")
trendline = ta.ema(close, input_trendline_length)
// strategy settings
input_long_orders = input.bool(true, "Long", group = "Strategy Settings")
input_short_orders = input.bool(true, "Short", group = "Strategy Settings")
//long
if close > trendline and lips > teeth and teeth > jaw and input_long_orders and strategy.opentrades == 0
strategy.entry("Long", strategy.long)
label.new(bar_index, low, text = "🟢 Long", style = label.style_label_up, color = #9cff87)
if close < trendline and lips < teeth and teeth < jaw
strategy.close("Long")
//short
if close < trendline and lips < teeth and teeth < jaw and input_short_orders and strategy.opentrades == 0
strategy.entry("Short", strategy.short)
label.new(bar_index, high, text = "🔴 Short", style = label.style_label_down, color = #f9396a, textcolor = color.white)
if close > trendline and lips > teeth and teeth > jaw
strategy.close("Short")
//ploting
plot(trendline, "Trendline", color = #9cff87, linewidth = 3)
plot(jaw, "Jaw", offset = jawOffset, color=#b3e9c7)
plot(teeth, "Teeth", offset = teethOffset, color=#c2f8cb)
plot(lips, "Lips", offset = lipsOffset, color=#f0fff1)