esta é a documentação do indicador million Moves algo para tradingview
https://docs.million-moves.net/
voce sabe qual metodo usado nele para confirmar e mostrar no grafico sinais de compra e venda?
O indicador Million Moves Algo usa vários tipos de sinais para confirmar e mostrar sinais de compra e venda no gráfico. Os principais tipos de sinais são:
Buy / Sell: Estes são sinais de pullback, ou seja, vão contra a direção atual da tendência.
Smart Buy / Smart Sell: Estes sinais se movem na mesma direção que a tendência atual, determinada pelo valor da Média Móvel nas configurações do Million Moves Algo.
Smart+ Buy / Smart+ Sell: Estes sinais acompanham a tendência atual e utilizam verificações adicionais para garantir que a tendência seja sólida, resultando em menos sinais gerais, mas de maior precisão.
Esses sinais permitem flexibilidade na negociação, possibilitando tanto negociações contra a tendência quanto a favor dela, dependendo da preferência e estratégia do trader (Documentation | Million Moves) (Documentation | Million Moves) (Documentation | Million Moves).
Para mais detalhes, você pode acessar a documentação completa aqui.
voce consegue ler oque esta nessa documentação?
ChatGPT
Sim, consigo ler a documentação do Million Moves Algo. Aqui estão os principais pontos sobre os sinais de compra e venda:
Tipos de Sinais
Buy / Sell:
Definição: Sinais de pullback, que vão contra a direção atual da tendência.
Uso: Utilizado para identificar oportunidades de compra ou venda contra a tendência.
Smart Buy / Smart Sell:
Definição: Sinais que se movem na mesma direção que a tendência atual.
Determinação da Tendência: A tendência é determinada pelo valor da Média Móvel nas configurações do Million Moves Algo.
Uso: Sinais mais alinhados com a tendência, indicam compra ou venda seguindo a direção da tendência.
Smart+ Buy / Smart+ Sell:
Definição: Sinais que acompanham a tendência atual e usam verificações adicionais para garantir a solidez da tendência.
Características: Menos sinais gerais, mas de maior precisão devido às verificações extras.
Uso: Recomendado para uso com alertas para melhor resultado.
Flexibilidade de Negociação
Os sinais fornecem flexibilidade para negociar de diferentes maneiras, seja contra a tendência ou acompanhando-a, permitindo que os traders ajustem suas estratégias de acordo com suas preferências e estilos de negociação.
Para mais informações, você pode acessar a documentação completa.
Se precisar de detalhes específicos ou seções adicionais da documentação, estou à disposição para ajudar!
com base no conhecimento dos detalhes da documentação voce consegue implementar ou melhorar deixando meu codigo mais fiel ao que acontece no indicador million moves algo?
//@version=5
indicator("Million Moves com Níveis de Entry, SL e TP", overlay=true)
// Parâmetros do indicador
length = input.int(14, title="Comprimento")
src = input(close, title="Fonte")
sl_atr_length = input.int(14, title="Comprimento do ATR para SL")
tp1 = input.float(1.5, title="Multiplicador TP1")
tp2 = input.float(3.0, title="Multiplicador TP2")
tp3 = input.float(4.5, title="Multiplicador TP3")
atr_multiplier = input.float(1.0, title="Multiplicador ATR para SL")
sma_length = input.int(20, title="Comprimento da SMA")
sma_offset = input.float(1.3, title="Deslocamento da SMA")
ema_length = input.int(9, title="Comprimento da EMA")
sma200_length = input.int(200, title="Comprimento da SMA 200")
// Determinação da cor da Chaos Trend Line
chaosColor = src > chaos_trend ? color.green : color.red
// Cálculo do ATR para Stop Loss
atr = ta.atr(sl_atr_length)
// Condições para a tendência
trendUp = src > ema and src > sma
trendDown = src < ema and src < sma
trendIndecisive = not (trendUp or trendDown)
// Sinais de Compra e Venda
buySignal = ta.crossover(src, sma)
sellSignal = ta.crossunder(src, sma)
// Inicializa os níveis como variáveis persistentes
var float entryPrice = na
var float slPrice = na
var float tp1Price = na
var float tp2Price = na
var float tp3Price = na
var bool lastBuySignal = na
var bool lastSellSignal = na
// Inicializa as labels
var label entryLabel = na
var label slLabel = na
var label tp1Label = na
var label tp2Label = na
var label tp3Label = na
// Atualiza os níveis quando há um sinal de compra ou venda
if (buySignal)
entryPrice := close
slPrice := entryPrice - atr * atr_multiplier
tp1Price := entryPrice + atr * tp1
tp2Price := entryPrice + atr * tp2
tp3Price := entryPrice + atr * tp3
lastBuySignal := true
lastSellSignal := false
// Condições para os sinais inteligentes
smartBuySignal = buySignal and trendUp
smartSellSignal = sellSignal and trendDown
plusSmartBuySignal = smartBuySignal and emaColor == color.green and chaosColor == color.green and trendUp
plusSmartSellSignal = smartSellSignal and emaColor == color.red and chaosColor == color.red and trendDown
// Plota a Média Móvel Simples com deslocamento
plot(sma, color=smaColor, title="SMA", linewidth=2)
// Plota a Média Móvel Exponencial
plot(ema, color=emaColor, title="EMA", linewidth=1)
// Plota a Média Móvel Simples de 200 períodos
plot(sma200, color=sma200Color, title="SMA 200", linewidth=2)
// Plota Sinais de Compra e Venda (Contra a Tendência)
plotshape(series=buySignal and not trendUp, location=location.belowbar, color=color.yellow, style=shape.labelup, text="BUY\nAgainst the Trend")
plotshape(series=sellSignal and not trendDown, location=location.abovebar, color=color.orange, style=shape.labeldown, text="SELL\nAgainst the Trend")
// Plota Sinais Inteligentes (Com a Tendência)
plotshape(series=smartBuySignal and trendUp, location=location.belowbar, color=color.green, style=shape.labelup, text="Smart BUY")
plotshape(series=smartSellSignal and trendDown, location=location.abovebar, color=color.red, style=shape.labeldown, text="Smart SELL")
// Plota Sinais de +Smart Buy / +Smart Sell (Com a Tendência e Confirmações)
plotshape(series=plusSmartBuySignal, location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, text="+Smart BUY")
plotshape(series=plusSmartSellSignal, location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text="+Smart SELL")
// Plota o Trend Cloud entre a SMA e a EMA
sma_ema_color = src > ema ? color.new(smaColor, 90) : color.new(emaColor, 90)
sma_plot = plot(sma, title="Trend Cloud SMA", color=color.new(smaColor, 90), linewidth=2, style=plot.style_line)
ema_plot = plot(ema, title="Trend Cloud EMA", color=color.new(emaColor, 90), linewidth=2, style=plot.style_line)
fill(sma_plot, ema_plot, color=sma_ema_color, title="Trend Cloud")
// Identificação dos Order Blocks
// Identificação dos Order Blocks
order_block_length = input.int(20, title="Comprimento do Order Block")
var float resistance_level = na
var float support_level = na
// Inicializa variáveis persistentes para armazenar os últimos níveis de resistência e suporte
var float last_resistance_level = na
var float last_support_level = na
// Função para calcular a força dos Order Blocks
calcOrderBlockStrength(level, isResistance) =>
distance = isResistance ? level - close : close - level
strength = distance / atr
strength
if (not na(high[1]) and high[1] == ta.highest(high, order_block_length))
resistance_level := high[1]
if (not na(low[1]) and low[1] == ta.lowest(low, order_block_length))
support_level := low[1]
// Plota os Order Blocks com verificação para evitar sobreposição
// Inicializa variáveis persistentes para armazenar os identificadores dos objetos dos Order Blocks
var box resistanceBox = na
var box supportBox = na
var line resistanceLine = na
var line supportLine = na
var label resistanceLabel = na
var label supportLabel = na
if (not na(resistance_level) and (na(last_resistance_level) or (resistance_level != last_resistance_level)))
// Deleta o Order Block anterior se existir
if (not na(resistanceBox))
box.delete(resistanceBox)
// Deleta a linha anterior se existir
if (not na(resistanceLine))
line.delete(resistanceLine)
// Deleta a label anterior se existir
if (not na(resistanceLabel))
label.delete(resistanceLabel)
// Cria um novo Order Block e armazena seu identificador
resistanceBox := box.new(left=bar_index - order_block_length, top=resistance_level, right=bar_index, bottom=resistance_level - atr * atr_multiplier, border_color=color.red, bgcolor=color.new(color.red, 90))
// Calcula e plota a força do Order Block
resistanceStrength = calcOrderBlockStrength(resistance_level, true)
resistanceLabel := label.new(bar_index, resistance_level, text="Resistência " + (resistanceStrength > 1 ? "Forte" : "Fraca"), color=color.red, textcolor=color.white, style=label.style_label_left, size=size.small)
last_resistance_level := resistance_level
if (not na(support_level) and (na(last_support_level) or (support_level != last_support_level)))
// Deleta o Order Block anterior se existir
if (not na(supportBox))
box.delete(supportBox)
// Deleta a linha anterior se existir
if (not na(supportLine))
line.delete(supportLine)
// Deleta a label anterior se existir
if (not na(supportLabel))
label.delete(supportLabel)
// Cria um novo Order Block e armazena seu identificador
supportBox := box.new(left=bar_index - order_block_length, top=support_level + atr * atr_multiplier, right=bar_index, bottom=support_level, border_color=color.green, bgcolor=color.new(color.green, 90))
// Calcula e plota a força do Order Block
supportStrength = calcOrderBlockStrength(support_level, false)
supportLabel := label.new(bar_index, support_level, text="Suporte " + (supportStrength > 1 ? "Forte" : "Fraco"), color=color.green, textcolor=color.white, style=label.style_label_left, size=size.small)
last_support_level := support_level
// Plota linhas verticais para sobrecompra e sobrevenda
overbought = 70
oversold = 30
rsi_length = input.int(14, title="Comprimento do RSI")
rsi = ta.rsi(src, rsi_length)
// Alertas
alertcondition(buySignal, title="Sinal de Compra", message="Sinal de Compra!")
alertcondition(sellSignal, title="Sinal de Venda", message="Sinal de Venda!")
alertcondition(smartBuySignal, title="Smart Sinal de Compra", message="Smart Sinal de Compra!")
alertcondition(smartSellSignal, title="Smart Sinal de Venda", message="Smart Sinal de Venda!")
alertcondition(plusSmartBuySignal, title="+Smart Sinal de Compra", message="+Smart Sinal de Compra!")
alertcondition(plusSmartSellSignal, title="+Smart Sinal de Venda", message="+Smart Sinal de Venda!")
principalmente na questao de confirmação de sinais de compra e venda
Assistant
Para deixar seu código mais fiel ao funcionamento do indicador Million Moves Algo, vamos seguir a lógica dos sinais descrita na documentação. Como mencionado, existem três tipos de sinais principais: Buy/Sell, Smart Buy/Smart Sell, e Smart+ Buy/Smart+ Sell. Vamos detalhar e ajustar o código para refletir esses sinais de maneira adequada.
1. Buy / Sell
Sinais de pullback que vão contra a direção atual da tendência.
2. Smart Buy / Smart Sell
Sinais que se movem na mesma direção que a tendência atual, determinada pela Média Móvel.
3. Smart+ Buy / Smart+ Sell
Sinais que acompanham a tendência atual e utilizam verificações adicionais para garantir a solidez da tendência, resultando em menos sinais gerais, mas de maior precisão.
Implementação
Vamos ajustar seu código Pine Script e decompor os diferentes sinais de forma a refletir o comportamento descrito na documentação.
pinescript
User
consegue deixar ele completo fiel com tudo que tem no indicador original com base na documentação?
Assistant
Para replicar completamente o indicador Million Moves Algo de acordo com a documentação, precisaremos incorporar todos os aspectos mencionados, incluindo médias móveis, sinais inteligentes, verificação de tendências, ordens de compra e venda com níveis de entrada, stop loss e take profit, bem como a identificação de suportes e resistências.
Vou reestruturar seu script Pine para que ele alinhe-se da maneira mais fiel possível ao descrito na documentação do indicador Million Moves Algo:
// Parâmetros do Indicador
length = input.int(14, title="Comprimento")
src = input(close, title="Fonte")
ema_length = input.int(9, title="Comprimento da EMA")
sma_length = input.int(20, title="Comprimento da SMA")
sma200_length = input.int(200, title="Comprimento da SMA 200")
atr_length = input.int(14, title="Comprimento do ATR")
atr_multiplier = input.float(1.0, title="Multiplicador ATR para SL")
tp1 = input.float(1.5, title="Multiplicador TP1")
tp2 = input.float(3.0, title="Multiplicador TP2")
tp3 = input.float(4.5, title="Multiplicador TP3")
// Médias Móveis
sma = ta.sma(src, sma_length)
ema = ta.ema(src, ema_length)
sma200 = ta.sma(src, sma200_length)
atr = ta.atr(atr_length)
// Determinação da cor da SMA e EMA
smaColor = src > sma ? color.green : color.red
emaColor = src > ema ? color.green : color.red
sma200Color = src > sma200 ? color.green : color.red
// Determinação da cor da tendência
trendUp = src > ema and src > sma
trendDown = src < ema and src < sma
// Sinais de Compra e Venda (Pullback)
buySignal = ta.crossover(src, sma)
sellSignal = ta.crossunder(src, sma)
// Sinais Inteligentes (Com a Tendência)
smartBuySignal = buySignal and trendUp
smartSellSignal = sellSignal and trendDown
// Sinais +Smart (Com a Tendência e Confirmação Adicional)
plusSmartBuySignal = smartBuySignal and emaColor == color.green
plusSmartSellSignal = smartSellSignal and emaColor == color.red
// Plota Sinais de Compra e Venda (Contra a Tendência)
plotshape(series=buySignal and not trendUp, location=location.belowbar, color=color.yellow, style=shape.labelup, text="BUY\nPullback")
plotshape(series=sellSignal and not trendDown, location=location.abovebar, color=color.orange, style=shape.labeldown, text="SELL\nPullback")
// Plota Sinais Inteligentes (Com a Tendência)
plotshape(series=smartBuySignal and trendUp, location=location.belowbar, color=color.green, style=shape.labelup, text="Smart BUY")
plotshape(series=smartSellSignal and trendDown, location=location.abovebar, color=color.red, style=shape.labeldown, text="Smart SELL")
// Níveis de Entry, SL e TP
var float entryPrice = na
var float slPrice = na
var float tp1Price = na
var float tp2Price = na
var float tp3Price = na
// Labels para Entry, SL e TP
var label entryLabel = na
var label slLabel = na
var label tp1Label = na
var label tp2Label = na
var label tp3Label = na
Assistant
O erro ocorre porque "text" é uma palavra reservada no Pine Script e não pode ser usada como nome de argumento em uma função. Para corrigir isso, você pode renomear o argumento "text" para algo diferente, como "label_text". Vou mostrar a correção no trecho específico da função create_label.
Antes:
pinescript
// Função para criar labels
create_label(label_ref, x, y, text, color, style) =>
if (not na(label_ref))
label.delete(label_ref)
label.new(x, y, text=text, color=color, textcolor=color.white, style=style, size=size.small)
Depois:
pinescript
// Função para criar labels
create_label(label_ref, x, y, label_text, color, style) =>
if (not na(label_ref))
label.delete(label_ref)
label.new(x, y, text=label_text, color=color, textcolor=color.white, style=style, size=size.small)
Código Completamente Corrigido:
pinescript
User
com base no codigo acima que voce gerou preciso que voce corrija esse meu codigo abaixo pois em algum ativos nao esta funcionando corretamente:
//@version=5
indicator("Million Moves com Níveis de Entry, SL e TP", overlay=true)
// Parâmetros do indicador
length = input.int(14, title="Comprimento")
src = input(close, title="Fonte")
sl_atr_length = input.int(14, title="Comprimento do ATR para SL")
tp1 = input.float(1.5, title="Multiplicador TP1")
tp2 = input.float(3.0, title="Multiplicador TP2")
tp3 = input.float(4.5, title="Multiplicador TP3")
atr_multiplier = input.float(1.0, title="Multiplicador ATR para SL")
sma_length = input.int(20, title="Comprimento da SMA")
sma_offset = input.float(1.3, title="Deslocamento da SMA")
ema_length = input.int(9, title="Comprimento da EMA")
sma200_length = input.int(200, title="Comprimento da SMA 200")
// Determinação da cor da Chaos Trend Line
chaosColor = src > chaos_trend ? color.green : color.red
// Cálculo do ATR para Stop Loss
atr = ta.atr(sl_atr_length)
// Condições para a tendência
trendUp = src > ema and src > sma
trendDown = src < ema and src < sma
trendIndecisive = not (trendUp or trendDown)
// Sinais de Compra e Venda
buySignal = ta.crossover(src, sma)
sellSignal = ta.crossunder(src, sma)
// Inicializa os níveis como variáveis persistentes
var float entryPrice = na
var float slPrice = na
var float tp1Price = na
var float tp2Price = na
var float tp3Price = na
var bool lastBuySignal = na
var bool lastSellSignal = na
Assistant
Vamos revisar seu código, garantir a correção de possíveis bugs e abordar os pontos que podem não estar funcionando corretamente em alguns ativos.
Revisões e Ajustes:
Correção de Parâmetros e Cálculos:
Certifique-se de que os cálculos das médias móveis, ATR e outros parâmetros estão corretos.
Limpeza e Organização do Código:
Organize as seções de definição de variáveis, cálculos e plotagens.
Uso Correto de Variáveis Persistentes:
Assegure-se de que as variáveis persistentes são inicializadas e atualizadas corretamente.
Verificação de Condições:
Verifique os critérios de buy/sell signals e as condições de tendência.
Código Corrigido:
pinescript
User
continue de onde parou apartir de:
var table dashboard = table.new(position.top_right, 3, 10)
Assistant
Certo, vou continuar o código a partir da definição da tabela dashboard para completar a implementação:
continue de onde parou apartir de :
var table dashboard = table.new(position.top_right, 3, 10)
Assistant
Claro, continuarei o código a partir da definição da tabela dashboard.
pinescript
Dataset releases
Not yet included in a published release.
//@version=5
indicator("Million Moves Algo Traduzido", overlay=true)
// Parâmetros do Indicador
length = input.int(14, title="Comprimento")
src = input(close, title="Fonte")
ema_length = input.int(9, title="Comprimento da EMA")
sma_length = input.int(20, title="Comprimento da SMA")
atr_length = input.int(14, title="Comprimento do ATR")
atr_multiplier = input.float(1.0, title="Multiplicador ATR para SL")
// Médias Móveis
sma = ta.sma(src, sma_length)
ema = ta.ema(src, ema_length)
atr = ta.atr(atr_length)
// Determinação da cor da SMA e EMA
smaColor = src > sma ? color.green : color.red
emaColor = src > ema ? color.green : color.red
// Determinação da cor da tendência
trendUp = src > ema and src > sma
trendDown = src < ema and src < sma
// Sinais de Compra e Venda (Pullback)
buySignal = ta.crossover(src, sma)
sellSignal = ta.crossunder(src, sma)
// Sinais Inteligentes (Com a Tendência)
smartBuySignal = buySignal and trendUp
smartSellSignal = sellSignal and trendDown
// Sinais +Smart (Com a Tendência e Confirmação Adicional)
plusSmartBuySignal = smartBuySignal and emaColor == color.green
plusSmartSellSignal = smartSellSignal and emaColor == color.red
// Plota Médias Móveis
plot(sma, color=smaColor, title="SMA", linewidth=2)
plot(ema, color=emaColor, title="EMA", linewidth=2)
// Plota Sinais de Compra e Venda (Contra a Tendência)
plotshape(series=buySignal and not trendUp, location=location.belowbar, color=color.yellow, style=shape.labelup, text="BUY\nPullback")
plotshape(series=sellSignal and not trendDown, location=location.abovebar, color=color.orange, style=shape.labeldown, text="SELL\nPullback")
// Plota Sinais Inteligentes (Com a Tendência)
plotshape(series=smartBuySignal and trendUp, location=location.belowbar, color=color.green, style=shape.labelup, text="Smart BUY")
plotshape(series=smartSellSignal and trendDown, location=location.abovebar, color=color.red, style=shape.labeldown, text="Smart SELL")
// Plota Sinais +Smart (Com a Tendência e Confirmações Adicionais)
plotshape(series=plusSmartBuySignal, location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, text="+Smart BUY")
plotshape(series=plusSmartSellSignal, location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text="+Smart SELL")
// Alertas para Sinais
alertcondition(buySignal, title="Sinal de Compra", message="Sinal de Compra!")
alertcondition(sellSignal, title="Sinal de Venda", message="Sinal de Venda!")
alertcondition(smartBuySignal, title="Smart Sinal de Compra", message="Smart Sinal de Compra!")
alertcondition(smartSellSignal, title="Smart Sinal de Venda", message="Smart Sinal de Venda!")
alertcondition(plusSmartBuySignal, title="+Smart Sinal de Compra", message="+Smart Sinal de Compra!")
alertcondition(plusSmartSellSignal, title="+Smart Sinal de Venda", message="+Smart Sinal de Venda!")
Explicações dos Ajustes:
Buy / Sell (Pullback):
Definição: Sinais de pullback que vão contra a direção atual da tendência.
Implementação: Usamos ta.crossover para Buy e ta.crossunder para Sell, mas apenas quando a tendência principal não está confirmada (i.e., not trendUp para Buy e not trendDown para Sell).
Smart Buy / Smart Sell:
Definição: Sinais que se movem na mesma direção que a tendência atual.
Implementação: Combinação dos sinais de Buy/Sell com a verificação da tendência (trendUp para Buy e trendDown para Sell).
Smart+ Buy / Smart+ Sell:
Definição: Sinais que acompanham a tendência atual e utilizam verificações adicionais (ex: EMA).
Implementação: Sinais mais restritos adicionando a verificação da cor da EMA.
Conclusão:
Com estes ajustes, o código deve refletir de maneira mais precisa a lógica dos sinais de compra e venda conforme descrita na documentação do indicador Million Moves Algo. Se precisar de mais ajustes ou funcionalidades, fique à vontade para perguntar!
//@version=5
indicator("Million Moves Algo", overlay=true)
// Parâmetros do Indicador
length = input.int(14, title="Comprimento")
src = input(close, title="Fonte")
ema_length = input.int(9, title="Comprimento da EMA")
sma_length = input.int(20, title="Comprimento da SMA")
sma200_length = input.int(200, title="Comprimento da SMA 200")
atr_length = input.int(14, title="Comprimento do ATR")
atr_multiplier = input.float(1.0, title="Multiplicador ATR para SL")
tp1 = input.float(1.5, title="Multiplicador TP1")
tp2 = input.float(3.0, title="Multiplicador TP2")
tp3 = input.float(4.5, title="Multiplicador TP3")
// Médias Móveis
sma = ta.sma(src, sma_length)
ema = ta.ema(src, ema_length)
sma200 = ta.sma(src, sma200_length)
atr = ta.atr(atr_length)
// Determinação da cor da SMA e EMA
smaColor = src > sma ? color.green : color.red
emaColor = src > ema ? color.green : color.red
sma200Color = src > sma200 ? color.green : color.red
// Determinação da cor da tendência
trendUp = src > ema and src > sma
trendDown = src < ema and src < sma
// Sinais de Compra e Venda (Pullback)
buySignal = ta.crossover(src, sma)
sellSignal = ta.crossunder(src, sma)
// Sinais Inteligentes (Com a Tendência)
smartBuySignal = buySignal and trendUp
smartSellSignal = sellSignal and trendDown
// Sinais +Smart (Com a Tendência e Confirmação Adicional)
plusSmartBuySignal = smartBuySignal and emaColor == color.green
plusSmartSellSignal = smartSellSignal and emaColor == color.red
// Plota Médias Móveis
plot(sma, color=smaColor, title="SMA", linewidth=2)
plot(ema, color=emaColor, title="EMA", linewidth=2)
plot(sma200, color=sma200Color, title="SMA 200", linewidth=2)
// Plota Sinais de Compra e Venda (Contra a Tendência)
plotshape(series=buySignal and not trendUp, location=location.belowbar, color=color.yellow, style=shape.labelup, text="BUY\nPullback")
plotshape(series=sellSignal and not trendDown, location=location.abovebar, color=color.orange, style=shape.labeldown, text="SELL\nPullback")
// Plota Sinais Inteligentes (Com a Tendência)
plotshape(series=smartBuySignal and trendUp, location=location.belowbar, color=color.green, style=shape.labelup, text="Smart BUY")
plotshape(series=smartSellSignal and trendDown, location=location.abovebar, color=color.red, style=shape.labeldown, text="Smart SELL")
// Plota Sinais +Smart (Com a Tendência e Confirmações Adicionais)
plotshape(series=plusSmartBuySignal, location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, text="+Smart BUY")
plotshape(series=plusSmartSellSignal, location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text="+Smart SELL")
// Níveis de Entry, SL e TP
var float entryPrice = na
var float slPrice = na
var float tp1Price = na
var float tp2Price = na
var float tp3Price = na
// Labels para Entry, SL e TP
var label entryLabel = na
var label slLabel = na
var label tp1Label = na
var label tp2Label = na
var label tp3Label = na
// Função para criar labels
create_label(label_ref, x, y, text, color, style) =>
if (not na(label_ref))
label.delete(label_ref)
label.new(x, y, text=text, color=color, textcolor=color.white, style=style, size=size.small)
// Atualiza os níveis quando há um sinal de compra ou venda
if (buySignal or smartBuySignal or plusSmartBuySignal)
entryPrice := close
slPrice := entryPrice - atr * atr_multiplier
tp1Price := entryPrice + atr * tp1
tp2Price := entryPrice + atr * tp2
tp3Price := entryPrice + atr * tp3
create_label(entryLabel, bar_index + 1, entryPrice, "Entry: " + str.tostring(entryPrice), color.blue, label.style_label_down)
create_label(slLabel, bar_index + 1, slPrice, "SL: " + str.tostring(slPrice), color.red, label.style_label_down)
create_label(tp1Label, bar_index + 1, tp1Price, "TP1: " + str.tostring(tp1Price), color.green, label.style_label_down)
create_label(tp2Label, bar_index + 1, tp2Price, "TP2: " + str.tostring(tp2Price), color.green, label.style_label_down)
create_label(tp3Label, bar_index + 1, tp3Price, "TP3: " + str.tostring(tp3Price), color.green, label.style_label_down)
if (sellSignal or smartSellSignal or plusSmartSellSignal)
entryPrice := close
slPrice := entryPrice + atr * atr_multiplier
tp1Price := entryPrice - atr * tp1
tp2Price := entryPrice - atr * tp2
tp3Price := entryPrice - atr * tp3
create_label(entryLabel, bar_index + 1, entryPrice, "Entry: " + str.tostring(entryPrice), color.blue, label.style_label_up)
create_label(slLabel, bar_index + 1, slPrice, "SL: " + str.tostring(slPrice), color.red, label.style_label_up)
create_label(tp1Label, bar_index + 1, tp1Price, "TP1: " + str.tostring(tp1Price), color.green, label.style_label_up)
create_label(tp2Label, bar_index + 1, tp2Price, "TP2: " + str.tostring(tp2Price), color.green, label.style_label_up)
create_label(tp3Label, bar_index + 1, tp3Price, "TP3: " + str.tostring(tp3Price), color.green, label.style_label_up)
// Identificação dos Order Blocks
order_block_length = input.int(20, title="Comprimento do Order Block")
var float resistance_level = na
var float support_level = na
if (not na(high[1]) and high[1] == ta.highest(high, order_block_length))
resistance_level := high[1]
if (not na(low[1]) and low[1] == ta.lowest(low, order_block_length))
support_level := low[1]
// Plota os Order Blocks com verificação para evitar sobreposição
var box resistanceBox = na
var box supportBox = na
var label resistanceLabel = na
var label supportLabel = na
if (not na(resistance_level))
if (not na(resistanceBox))
box.delete(resistanceBox)
if (not na(resistanceLabel))
label.delete(resistanceLabel)
resistanceBox := box.new(left=bar_index - order_block_length, top=resistance_level, right=bar_index, bottom=resistance_level, border_color=color.red, bgcolor=color.new(color.red, 90))
resistanceLabel := label.new(bar_index, resistance_level, text="Resistance", color=color.red, textcolor=color.white, style=label.style_label_left, size=size.small)
if (not na(support_level))
if (not na(supportBox))
box.delete(supportBox)
if (not na(supportLabel))
label.delete(supportLabel)
supportBox := box.new(left=bar_index - order_block_length, top=support_level, right=bar_index, bottom=support_level, border_color=color.green, bgcolor=color.new(color.green, 90))
supportLabel := label.new(bar_index, support_level, text="Support", color=color.green, textcolor=color.white, style=label.style_label_left, size=size.small)
// Cor das velas com base na tendência
barcolor(trendUp ? color.green : (trendDown ? color.red : na))
// Alertas
alertcondition(buySignal, title="Sinal de Compra", message="Sinal de Compra!")
alertcondition(sellSignal, title="Sinal de Venda", message="Sinal de Venda!")
alertcondition(smartBuySignal, title="Smart Sinal de Compra", message="Smart Sinal de Compra!")
alertcondition(smartSellSignal, title="Smart Sinal de Venda", message="Smart Sinal de Venda!")
alertcondition(plusSmartBuySignal, title="+Smart Sinal de Compra", message="+Smart Sinal de Compra!")
alertcondition(plusSmartSellSignal, title="+Smart Sinal de Venda", message="+Smart Sinal de Venda!")
Explicações dos Ajustes:
Médias Móveis:
Implementamos as SMA, EMA, e SMA200 básicas.
Sinais de Compra e Venda:
Buy/Sell Signal: Utiliza o cruzamento do preço com a SMA.
Smart Buy/Sell Signal: Confirma com a tendência usando cruzamento com a média móvel e verificação da tendência.
+Smart Buy/Sell Signal: Confirma os sinais inteligentes com verificações adicionais como a cor da EMA.
Níveis de Entry, SL e TP:
Calculamos SL e TP com base no ATR.
Identificação dos Order Blocks:
Identificamos níveis de resistência e suporte com base em altos e baixos no comprimento definido de candles.
Cor das Velas:
Alteramos a cor das velas com base na tendência (verde para tendência de alta e vermelho para tendência de baixa).
Alertas:
Configuramos alertas para cada tipo de sinal.
Conclusão:
Este script deve cobrir a funcionalidade do Million Moves Algo conforme a documentação fornecida. Se precisar de mais alguma funcionalidade ou ajustes específicos, sinta-se à vontade para perguntar!
// Função para criar labels
create_label(label_ref, x, y, text, color, style) =>
if (not na(label_ref))
label.delete(label_ref)
label.new(x, y, text=text, color=color, textcolor=color.white, style=style, size=size.small)
// Atualiza os níveis quando há um sinal de compra ou venda
if (buySignal or smartBuySignal or plusSmartBuySignal)
entryPrice := close
slPrice := entryPrice - atr * atr_multiplier
tp1Price := entryPrice + atr * tp1
tp2Price := entryPrice + atr * tp2
tp3Price := entryPrice + atr * tp3
// Identificação dos Order Blocks
order_block_length = input.int(20, title="Comprimento do Order Block")
var float resistance_level = na
var float support_level = na
if (not na(high[1]) and high[1] == ta.highest(high, order_block_length))
resistance_level := high[1]
if (not na(low[1]) and low[1] == ta.lowest(low, order_block_length))
support_level := low[1]
// Plota os Order Blocks com verificação para evitar sobreposição
var box resistanceBox = na
var box supportBox = na
var label resistanceLabel = na
var label supportLabel = na
// Cor das velas com base na tendência
barcolor(trendUp ? color.green : (trendDown ? color.red : na))
// Alertas
alertcondition(buySignal, title="Sinal de Compra", message="Sinal de Compra!")
alertcondition(sellSignal, title="Sinal de Venda", message="Sinal de Venda!")
alertcondition(smartBuySignal, title="Smart Sinal de Compra", message="Smart Sinal de Compra!")
alertcondition(smartSellSignal, title="Smart Sinal de Venda", message="Smart Sinal de Venda!")
alertcondition(plusSmartBuySignal, title="+Smart Sinal de Compra", message="+Smart Sinal de Compra!")
alertcondition(plusSmartSellSignal, title="+Smart Sinal de Venda", message="+Smart Sinal de Venda!")
erro abaixo:
create_label(label_ref, x, y, text, color, style) =>
Erro em 75:31 'text' cannot be used as a variable or function name.
me mostre o trecho do antes e depois da conrreção
//@version=5
indicator("Million Moves Algo", overlay=true)
// Parâmetros do Indicador
length = input.int(14, title="Comprimento")
src = input(close, title="Fonte")
ema_length = input.int(9, title="Comprimento da EMA")
sma_length = input.int(20, title="Comprimento da SMA")
sma200_length = input.int(200, title="Comprimento da SMA 200")
atr_length = input.int(14, title="Comprimento do ATR")
atr_multiplier = input.float(1.0, title="Multiplicador ATR para SL")
tp1 = input.float(1.5, title="Multiplicador TP1")
tp2 = input.float(3.0, title="Multiplicador TP2")
tp3 = input.float(4.5, title="Multiplicador TP3")
// Médias Móveis
sma = ta.sma(src, sma_length)
ema = ta.ema(src, ema_length)
sma200 = ta.sma(src, sma200_length)
atr = ta.atr(atr_length)
// Determinação da cor da SMA e EMA
smaColor = src > sma ? color.green : color.red
emaColor = src > ema ? color.green : color.red
sma200Color = src > sma200 ? color.green : color.red
// Determinação da cor da tendência
trendUp = src > ema and src > sma
trendDown = src < ema and src < sma
// Sinais de Compra e Venda (Pullback)
buySignal = ta.crossover(src, sma)
sellSignal = ta.crossunder(src, sma)
// Sinais Inteligentes (Com a Tendência)
smartBuySignal = buySignal and trendUp
smartSellSignal = sellSignal and trendDown
// Sinais +Smart (Com a Tendência e Confirmação Adicional)
plusSmartBuySignal = smartBuySignal and emaColor == color.green
plusSmartSellSignal = smartSellSignal and emaColor == color.red
// Plota Médias Móveis
plot(sma, color=smaColor, title="SMA", linewidth=2)
plot(ema, color=emaColor, title="EMA", linewidth=2)
plot(sma200, color=sma200Color, title="SMA 200", linewidth=2)
// Plota Sinais de Compra e Venda (Contra a Tendência)
plotshape(series=buySignal and not trendUp, location=location.belowbar, color=color.yellow, style=shape.labelup, text="BUY\nPullback")
plotshape(series=sellSignal and not trendDown, location=location.abovebar, color=color.orange, style=shape.labeldown, text="SELL\nPullback")
// Plota Sinais Inteligentes (Com a Tendência)
plotshape(series=smartBuySignal and trendUp, location=location.belowbar, color=color.green, style=shape.labelup, text="Smart BUY")
plotshape(series=smartSellSignal and trendDown, location=location.abovebar, color=color.red, style=shape.labeldown, text="Smart SELL")
// Plota Sinais +Smart (Com a Tendência e Confirmações Adicionais)
plotshape(series=plusSmartBuySignal, location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, text="+Smart BUY")
plotshape(series=plusSmartSellSignal, location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text="+Smart SELL")
// Níveis de Entry, SL e TP
var float entryPrice = na
var float slPrice = na
var float tp1Price = na
var float tp2Price = na
var float tp3Price = na
// Labels para Entry, SL e TP
var label entryLabel = na
var label slLabel = na
var label tp1Label = na
var label tp2Label = na
var label tp3Label = na
// Função para criar labels
create_label(label_ref, x, y, label_text, color, style) =>
if (not na(label_ref))
label.delete(label_ref)
label.new(x, y, text=label_text, color=color, textcolor=color.white, style=style, size=size.small)
// Atualiza os níveis quando há um sinal de compra ou venda
if (buySignal or smartBuySignal or plusSmartBuySignal)
entryPrice := close
slPrice := entryPrice - atr * atr_multiplier
tp1Price := entryPrice + atr * tp1
tp2Price := entryPrice + atr * tp2
tp3Price := entryPrice + atr * tp3
create_label(entryLabel, bar_index + 1, entryPrice, "Entry: " + str.tostring(entryPrice), color.blue, label.style_label_down)
create_label(slLabel, bar_index + 1, slPrice, "SL: " + str.tostring(slPrice), color.red, label.style_label_down)
create_label(tp1Label, bar_index + 1, tp1Price, "TP1: " + str.tostring(tp1Price), color.green, label.style_label_down)
create_label(tp2Label, bar_index + 1, tp2Price, "TP2: " + str.tostring(tp2Price), color.green, label.style_label_down)
create_label(tp3Label, bar_index + 1, tp3Price, "TP3: " + str.tostring(tp3Price), color.green, label.style_label_down)
if (sellSignal or smartSellSignal or plusSmartSellSignal)
entryPrice := close
slPrice := entryPrice + atr * atr_multiplier
tp1Price := entryPrice - atr * tp1
tp2Price := entryPrice - atr * tp2
tp3Price := entryPrice - atr * tp3
create_label(entryLabel, bar_index + 1, entryPrice, "Entry: " + str.tostring(entryPrice), color.blue, label.style_label_up)
create_label(slLabel, bar_index + 1, slPrice, "SL: " + str.tostring(slPrice), color.red, label.style_label_up)
create_label(tp1Label, bar_index + 1, tp1Price, "TP1: " + str.tostring(tp1Price), color.green, label.style_label_up)
create_label(tp2Label, bar_index + 1, tp2Price, "TP2: " + str.tostring(tp2Price), color.green, label.style_label_up)
create_label(tp3Label, bar_index + 1, tp3Price, "TP3: " + str.tostring(tp3Price), color.green, label.style_label_up)
// Identificação dos Order Blocks
order_block_length = input.int(20, title="Comprimento do Order Block")
var float resistance_level = na
var float support_level = na
if (not na(high[1]) and high[1] == ta.highest(high, order_block_length))
resistance_level := high[1]
if (not na(low[1]) and low[1] == ta.lowest(low, order_block_length))
support_level := low[1]
// Plota os Order Blocks com verificação para evitar sobreposição
var box resistanceBox = na
var box supportBox = na
var label resistanceLabel = na
var label supportLabel = na
if (not na(resistance_level))
if (not na(resistanceBox))
box.delete(resistanceBox)
if (not na(resistanceLabel))
label.delete(resistanceLabel)
resistanceBox := box.new(left=bar_index - order_block_length, top=resistance_level, right=bar_index, bottom=resistance_level, border_color=color.red, bgcolor=color.new(color.red, 90))
resistanceLabel := label.new(bar_index, resistance_level, text="Resistance", color=color.red, textcolor=color.white, style=label.style_label_left, size=size.small)
if (not na(support_level))
if (not na(supportBox))
box.delete(supportBox)
if (not na(supportLabel))
label.delete(supportLabel)
supportBox := box.new(left=bar_index - order_block_length, top=support_level, right=bar_index, bottom=support_level, border_color=color.green, bgcolor=color.new(color.green, 90))
supportLabel := label.new(bar_index, support_level, text="Support", color=color.green, textcolor=color.white, style=label.style_label_left, size=size.small)
// Cor das velas com base na tendência
barcolor(trendUp ? color.green : (trendDown ? color.red : na))
// Alertas
alertcondition(buySignal, title="Sinal de Compra", message="Sinal de Compra!")
alertcondition(sellSignal, title="Sinal de Venda", message="Sinal de Venda!")
alertcondition(smartBuySignal, title="Smart Sinal de Compra", message="Smart Sinal de Compra!")
alertcondition(smartSellSignal, title="Smart Sinal de Venda", message="Smart Sinal de Venda!")
alertcondition(plusSmartBuySignal, title="+Smart Sinal de Compra", message="+Smart Sinal de Compra!")
alertcondition(plusSmartSellSignal, title="+Smart Sinal de Venda", message="+Smart Sinal de Venda!")
Conclusão:
Com essa correção, seu script Pine deve agora funcionar corretamente sem o erro associado ao uso de "text" como um nome de argumento. Se precisar de mais ajustes ou funcionalidades, sinta-se à vontade para perguntar!
// Inicializa as labels
var label entryLabel = na
var label slLabel = na
var label tp1Label = na
var label tp2Label = na
var label tp3Label = na
// Atualiza os níveis quando há um sinal de compra ou venda
if (buySignal)
entryPrice := close
slPrice := entryPrice - atr * atr_multiplier
tp1Price := entryPrice + atr * tp1
tp2Price := entryPrice + atr * tp2
tp3Price := entryPrice + atr * tp3
lastBuySignal := true
lastSellSignal := false
// Condições para os sinais inteligentes
smartBuySignal = buySignal and trendUp
smartSellSignal = sellSignal and trendDown
plusSmartBuySignal = smartBuySignal and emaColor == color.green and chaosColor == color.green and trendUp
plusSmartSellSignal = smartSellSignal and emaColor == color.red and chaosColor == color.red and trendDown
// Plota a Média Móvel Simples com deslocamento
plot(sma, color=smaColor, title="SMA", linewidth=2)
// Plota a Média Móvel Exponencial
plot(ema, color=emaColor, title="EMA", linewidth=1)
// Plota a Média Móvel Simples de 200 períodos
plot(sma200, color=sma200Color, title="SMA 200", linewidth=2)
// Plota Sinais de Compra e Venda (Contra a Tendência)
plotshape(series=buySignal and not trendUp, location=location.belowbar, color=color.yellow, style=shape.labelup, text="BUY\nAgainst the Trend")
plotshape(series=sellSignal and not trendDown, location=location.abovebar, color=color.orange, style=shape.labeldown, text="SELL\nAgainst the Trend")
// Plota Sinais Inteligentes (Com a Tendência)
plotshape(series=smartBuySignal and trendUp, location=location.belowbar, color=color.green, style=shape.labelup, text="Smart BUY")
plotshape(series=smartSellSignal and trendDown, location=location.abovebar, color=color.red, style=shape.labeldown, text="Smart SELL")
// Plota Sinais de +Smart Buy / +Smart Sell (Com a Tendência e Confirmações)
plotshape(series=plusSmartBuySignal, location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, text="+Smart BUY")
plotshape(series=plusSmartSellSignal, location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text="+Smart SELL")
// Plota o Trend Cloud entre a SMA e a EMA
sma_ema_color = src > ema ? color.new(smaColor, 90) : color.new(emaColor, 90)
sma_plot = plot(sma, title="Trend Cloud SMA", color=color.new(smaColor, 90), linewidth=2, style=plot.style_line)
ema_plot = plot(ema, title="Trend Cloud EMA", color=color.new(emaColor, 90), linewidth=2, style=plot.style_line)
fill(sma_plot, ema_plot, color=sma_ema_color, title="Trend Cloud")
// Identificação dos Order Blocks
// Identificação dos Order Blocks
order_block_length = input.int(20, title="Comprimento do Order Block")
var float resistance_level = na
var float support_level = na
// Inicializa variáveis persistentes para armazenar os últimos níveis de resistência e suporte
var float last_resistance_level = na
var float last_support_level = na
// Função para calcular a força dos Order Blocks
calcOrderBlockStrength(level, isResistance) =>
distance = isResistance ? level - close : close - level
strength = distance / atr
strength
if (not na(high[1]) and high[1] == ta.highest(high, order_block_length))
resistance_level := high[1]
if (not na(low[1]) and low[1] == ta.lowest(low, order_block_length))
support_level := low[1]
// Plota os Order Blocks com verificação para evitar sobreposição
// Inicializa variáveis persistentes para armazenar os identificadores dos objetos dos Order Blocks
var box resistanceBox = na
var box supportBox = na
var line resistanceLine = na
var line supportLine = na
var label resistanceLabel = na
var label supportLabel = na
if (not na(resistance_level) and (na(last_resistance_level) or (resistance_level != last_resistance_level)))
// Deleta o Order Block anterior se existir
if (not na(resistanceBox))
box.delete(resistanceBox)
// Deleta a linha anterior se existir
if (not na(resistanceLine))
line.delete(resistanceLine)
// Deleta a label anterior se existir
if (not na(resistanceLabel))
label.delete(resistanceLabel)
// Cria um novo Order Block e armazena seu identificador
resistanceBox := box.new(left=bar_index - order_block_length, top=resistance_level, right=bar_index, bottom=resistance_level - atr * atr_multiplier, border_color=color.red, bgcolor=color.new(color.red, 90))
// Calcula e plota a força do Order Block
resistanceStrength = calcOrderBlockStrength(resistance_level, true)
resistanceLabel := label.new(bar_index, resistance_level, text="Resistência " + (resistanceStrength > 1 ? "Forte" : "Fraca"), color=color.red, textcolor=color.white, style=label.style_label_left, size=size.small)
last_resistance_level := resistance_level
if (not na(support_level) and (na(last_support_level) or (support_level != last_support_level)))
// Deleta o Order Block anterior se existir
if (not na(supportBox))
box.delete(supportBox)
// Deleta a linha anterior se existir
if (not na(supportLine))
line.delete(supportLine)
// Deleta a label anterior se existir
if (not na(supportLabel))
label.delete(supportLabel)
// Cria um novo Order Block e armazena seu identificador
supportBox := box.new(left=bar_index - order_block_length, top=support_level + atr * atr_multiplier, right=bar_index, bottom=support_level, border_color=color.green, bgcolor=color.new(color.green, 90))
// Calcula e plota a força do Order Block
supportStrength = calcOrderBlockStrength(support_level, false)
supportLabel := label.new(bar_index, support_level, text="Suporte " + (supportStrength > 1 ? "Forte" : "Fraco"), color=color.green, textcolor=color.white, style=label.style_label_left, size=size.small)
last_support_level := support_level
// Plota linhas verticais para sobrecompra e sobrevenda
overbought = 70
oversold = 30
rsi_length = input.int(14, title="Comprimento do RSI")
rsi = ta.rsi(src, rsi_length)
// Alertas
alertcondition(buySignal, title="Sinal de Compra", message="Sinal de Compra!")
alertcondition(sellSignal, title="Sinal de Venda", message="Sinal de Venda!")
alertcondition(smartBuySignal, title="Smart Sinal de Compra", message="Smart Sinal de Compra!")
alertcondition(smartSellSignal, title="Smart Sinal de Venda", message="Smart Sinal de Venda!")
alertcondition(plusSmartBuySignal, title="+Smart Sinal de Compra", message="+Smart Sinal de Compra!")
alertcondition(plusSmartSellSignal, title="+Smart Sinal de Venda", message="+Smart Sinal de Venda!")
//@version=5
indicator("Million Moves com Níveis de Entry, SL e TP", overlay=true)
// Parâmetros do indicador
length = input.int(14, title="Comprimento")
src = input(close, title="Fonte")
sl_atr_length = input.int(14, title="Comprimento do ATR para SL")
tp1 = input.float(1.5, title="Multiplicador TP1")
tp2 = input.float(3.0, title="Multiplicador TP2")
tp3 = input.float(4.5, title="Multiplicador TP3")
atr_multiplier = input.float(1.0, title="Multiplicador ATR para SL")
sma_length = input.int(20, title="Comprimento da SMA")
sma_offset = input.float(1.3, title="Deslocamento da SMA")
ema_length = input.int(9, title="Comprimento da EMA")
sma200_length = input.int(200, title="Comprimento da SMA 200")
// Parâmetros do Moving Average Ribbon
ma1_length = input.int(5, title="Comprimento MA1")
ma2_length = input.int(10, title="Comprimento MA2")
ma3_length = input.int(15, title="Comprimento MA3")
ma4_length = input.int(20, title="Comprimento MA4")
ma5_length = input.int(25, title="Comprimento MA5")
// Média Móvel Simples (SMA) com deslocamento
sma = ta.sma(src, sma_length) + sma_offset
// Média Móvel Exponencial (EMA)
ema = ta.ema(src, ema_length)
// Média Móvel Simples de 200 períodos
sma200 = ta.sma(src, sma200_length)
// Médias Móveis do Moving Average Ribbon
ma1 = ta.sma(src, ma1_length)
ma2 = ta.sma(src, ma2_length)
ma3 = ta.sma(src, ma3_length)
ma4 = ta.sma(src, ma4_length)
ma5 = ta.sma(src, ma5_length)
// Chaos Trend Line (usando uma SMA de 100 períodos)
chaos_trend = ta.sma(src, 100)
// Determinação da cor das médias móveis
smaColor = src > sma ? color.green : color.red
emaColor = src > ema ? color.green : color.red
sma200Color = src > sma200 ? color.green : color.red
// Determinação das cores do Moving Average Ribbon
ma1Color = src > ma1 ? color.new(color.green, 80) : color.new(color.red, 80)
ma2Color = src > ma2 ? color.new(color.green, 80) : color.new(color.red, 80)
ma3Color = src > ma3 ? color.new(color.green, 80) : color.new(color.red, 80)
ma4Color = src > ma4 ? color.new(color.green, 80) : color.new(color.red, 80)
ma5Color = src > ma5 ? color.new(color.green, 80) : color.new(color.red, 80)
// Determinação da cor da Chaos Trend Line
chaosColor = src > chaos_trend ? color.green : color.red
// Cálculo do ATR para Stop Loss e Take Profit
atr = ta.atr(sl_atr_length)
// Condições para a tendência
trendUp = src > ema and src > sma
trendDown = src < ema and src < sma
// Sinais de Compra e Venda
buySignal = ta.crossover(src, sma)
sellSignal = ta.crossunder(src, sma)
// Inicialização de níveis e labels
var float entryPrice = na
var float slPrice = na
var float tp1Price = na
var float tp2Price = na
var float tp3Price = na
var bool lastBuySignal = na
var bool lastSellSignal = na
var label entryLabel = na
var label slLabel = na
var label tp1Label = na
var label tp2Label = na
var label tp3Label = na
// Função para criar labels
create_label(label_ref, x, y, label_text, color, style) =>
if (not na(label_ref))
label.delete(label_ref)
label.new(x, y, text=label_text, color=color, textcolor=color.white, style=style, size=size.small)
// Atualiza os níveis quando há um sinal de compra ou venda
if (buySignal or smartBuySignal or plusSmartBuySignal)
entryPrice := close
slPrice := entryPrice - atr * atr_multiplier
tp1Price := entryPrice + atr * tp1
tp2Price := entryPrice + atr * tp2
tp3Price := entryPrice + atr * tp3
create_label(entryLabel, bar_index + 1, entryPrice, "Entry: " + str.tostring(entryPrice), color.blue, label.style_label_down)
create_label(slLabel, bar_index + 1, slPrice, "SL: " + str.tostring(slPrice), color.red, label.style_label_down)
create_label(tp1Label, bar_index + 1, tp1Price, "TP1: " + str.tostring(tp1Price), color.green, label.style_label_down)
create_label(tp2Label, bar_index + 1, tp2Price, "TP2: " + str.tostring(tp2Price), color.green, label.style_label_down)
create_label(tp3Label, bar_index + 1, tp3Price, "TP3: " + str.tostring(tp3Price), color.green, label.style_label_down)
if (sellSignal or smartSellSignal or plusSmartSellSignal)
entryPrice := close
slPrice := entryPrice + atr * atr_multiplier
tp1Price := entryPrice - atr * tp1
tp2Price := entryPrice - atr * tp2
tp3Price := entryPrice - atr * tp3
create_label(entryLabel, bar_index + 1, entryPrice, "Entry: " + str.tostring(entryPrice), color.blue, label.style_label_up)
create_label(slLabel, bar_index + 1, slPrice, "SL: " + str.tostring(slPrice), color.red, label.style_label_up)
create_label(tp1Label, bar_index + 1, tp1Price, "TP1: " + str.tostring(tp1Price), color.green, label.style_label_up)
create_label(tp2Label, bar_index + 1, tp2Price, "TP2: " + str.tostring(tp2Price), color.green, label.style_label_up)
create_label(tp3Label, bar_index + 1, tp3Price, "TP3: " + str.tostring(tp3Price), color.green, label.style_label_up)
// Condições para os sinais inteligentes
smartBuySignal = buySignal and trendUp
smartSellSignal = sellSignal and trendDown
plusSmartBuySignal = smartBuySignal and emaColor == color.green and chaosColor == color.green and trendUp
plusSmartSellSignal = smartSellSignal and emaColor == color.red and chaosColor == color.red and trendDown
// Plota a Média Móvel Simples com deslocamento
plot(sma, color=smaColor, title="SMA", linewidth=2)
// Plota a Média Móvel Exponencial
plot(ema, color=emaColor, title="EMA", linewidth=1)
// Plota a Média Móvel Simples de 200 períodos
plot(sma200, color=sma200Color, title="SMA 200", linewidth=2)
// Plota as Médias Móveis do Moving Average Ribbon
plot(ma1, color=ma1Color, title="MA1", linewidth=1, style=plot.style_stepline)
plot(ma2, color=ma2Color, title="MA2", linewidth=1, style=plot.style_stepline)
plot(ma3, color=ma3Color, title="MA3", linewidth=1, style=plot.style_stepline)
plot(ma4, color=ma4Color, title="MA4", linewidth=1, style=plot.style_stepline)
plot(ma5, color=ma5Color, title="MA5", linewidth=1, style=plot.style_stepline)
// Plota Sinais de Compra e Venda (Contra a Tendência)
plotshape(series=buySignal and not trendUp, location=location.belowbar, color=color.yellow, style=shape.labelup, text="BUY\nAgainst the Trend")
plotshape(series=sellSignal and not trendDown, location=location.abovebar, color=color.orange, style=shape.labeldown, text="SELL\nAgainst the Trend")
// Plota Sinais Inteligentes (Com a Tendência)
plotshape(series=smartBuySignal and trendUp, location=location.belowbar, color=color.green, style=shape.labelup, text="Smart BUY")
plotshape(series=smartSellSignal and trendDown, location=location.abovebar, color=color.red, style=shape.labeldown, text="Smart SELL")
// Plota Sinais de +Smart Buy / +Smart Sell (Com a Tendência e Confirmações)
plotshape(series=plusSmartBuySignal, location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, text="+Smart BUY")
plotshape(series=plusSmartSellSignal, location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text="+Smart SELL")
// Plota o Trend Cloud entre a SMA e a EMA
sma_ema_color = src > ema ? color.new(smaColor, 90) : color.new(emaColor, 90)
sma_plot = plot(sma, title="Trend Cloud SMA", color=color.new(smaColor, 90), linewidth=2, style=plot.style_line)
ema_plot = plot(ema, title="Trend Cloud EMA", color=color.new(emaColor, 90), linewidth=2, style=plot.style_line)
fill(sma_plot, ema_plot, color=sma_ema_color, title="Trend Cloud")
// Identificação dos Order Blocks
order_block_length = input.int(20, title="Comprimento do Order Block")
var float resistance_level = na
var float support_level = na
// Inicializa variáveis persistentes para armazenar os últimos níveis de resistência e suporte
var float last_resistance_level = na
var float last_support_level = na
// Função para calcular a força dos Order Blocks
calcOrderBlockStrength(level, isResistance) =>
distance = isResistance ? level - close : close - level
strength = distance / atr
strength
if (not na(high[1]) and high[1] == ta.highest(high, order_block_length))
resistance_level := high[1]
if (not na(low[1]) and low[1] == ta.lowest(low, order_block_length))
support_level := low[1]
// Plota os Order Blocks com verificação para evitar sobreposição
// Inicializa variáveis persistentes para armazenar os identificadores dos objetos dos Order Blocks
var box resistanceBox = na
var box supportBox = na
var line resistanceLine = na
var line supportLine = na
var label resistanceLabel = na
var label supportLabel = na
if (not na(resistance_level) and (na(last_resistance_level) or (resistance_level != last_resistance_level)))
// Deleta o Order Block anterior se existir
if (not na(resistanceBox))
box.delete(resistanceBox)
// Deleta a linha anterior se existir
if (not na(resistanceLine))
line.delete(resistanceLine)
// Deleta a label anterior se existir
if (not na(resistanceLabel))
label.delete(resistanceLabel)
// Cria um novo Order Block e armazena seu identificador
resistanceBox := box.new(left=bar_index - order_block_length, top=resistance_level, right=bar_index, bottom=resistance_level - atr * atr_multiplier, border_color=color.red, bgcolor=color.new(color.red, 90))
// Calcula e plota a força do Order Block
resistanceStrength = calcOrderBlockStrength(resistance_level, true)
resistanceLabel := label.new(bar_index, resistance_level, text="Resistência " + (resistanceStrength > 1 ? "Forte" : "Fraca"), color=color.red, textcolor=color.white, style=label.style_label_left, size=size.small)
last_resistance_level := resistance_level
if (not na(support_level) and (na(last_support_level) or (support_level != last_support_level)))
// Deleta o Order Block anterior se existir
if (not na(supportBox))
box.delete(supportBox)
// Deleta a linha anterior se existir
if (not na(supportLine))
line.delete(supportLine)
// Deleta a label anterior se existir
if (not na(supportLabel))
label.delete(supportLabel)
// Cria um novo Order Block e armazena seu identificador
supportBox := box.new(left=bar_index - order_block_length, top=support_level + atr * atr_multiplier, right=bar_index, bottom=support_level, border_color=color.green, bgcolor=color.new(color.green, 90))
// Calcula e plota a força do Order Block
supportStrength = calcOrderBlockStrength(support_level, false)
supportLabel := label.new(bar_index, support_level, text="Suporte " + (supportStrength > 1 ? "Forte" : "Fraco"), color=color.green, textcolor=color.white, style=label.style_label_left, size=size.small)
// Plota linhas verticais para sobrecompra e sobrevenda
overbought = 70
oversold = 30
rsi_length = input.int(14, title="Comprimento do RSI")
rsi = ta.rsi(src, rsi_length)
if (rsi > overbought)
line.new(x1=bar_index, y1=low - atr * 2, x2=bar_index, y2=high + atr * 2, color=color.new(color.green, 80), width=3, style=line.style_solid)
if (rsi < oversold)
line.new(x1=bar_index, y1=low - atr * 2, x2=bar_index, y2=high + atr * 2, color=color.new(color.red, 80), width=3, style=line.style_solid)
// Cor das velas com base na tendência
barcolor(trendUp ? color.green : (trendDown ? color.red : color.purple))
// Dashboard de Tendência
rsiColor = rsi > 50 ? color.green : color.red
trendStrength = (trendUp or trendDown) ? (math.abs(ema - sma) > atr ? "Very High" : (math.abs(ema - sma) > atr * 0.75 ? "High" : (math.abs(ema - sma) > atr * 0.5 ? "Medium" : "Low"))) : "Indecisive"
trendStrengthColor = trendStrength == "Very High" ? color.green : (trendStrength == "High" ? color.blue : (trendStrength == "Medium" ? color.yellow : (trendStrength == "Low" ? color.red : color.gray)))
// Função para determinar tendências em diferentes timeframes
getTrend(timeframe) =>
[t_ema, t_sma] = request.security(syminfo.tickerid, timeframe, [ta.ema(close, ema_length), ta.sma(close, sma_length)])
t_trendUp = t_ema > t_sma
t_trendDown = t_ema < t_sma
t_trendUp ? "Bullish" : (t_trendDown ? "Bearish" : "Indecisive")
trend3m = getTrend("3")
trend5m = getTrend("5")
trend15m = getTrend("15")
trend1h = getTrend("60")
trend2h = getTrend("120")
trend4h = getTrend("240")
trend12h = getTrend("720")
trend1d = getTrend("D")
volatility = atr > sma * 0.02 ? "High" : "Low"
volatilityColor = volatility == "High" ? color.red : color.green
var table dashboard = table.new(position.top_right, 3, 10)
table.cell(dashboard, 0, 0, text="RSI: " + str.tostring(rsi), text_color=rsiColor, text_size=size.small)
table.cell(dashboard, 0, 1, text="Trend Strength: " + trendStrength, text_color=trendStrengthColor, text_size=size.small)
table.cell(dashboard, 0, 2, text="3m Trend: " + trend3m, text_color=(trend3m == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 3, text="5m Trend: " + trend5m, text_color=(trend5m == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 4, text="15m Trend: " + trend15m, text_color=(trend15m == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 5, text="1h Trend: " + trend1h, text_color=(trend1h == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 6, text="2h Trend: " + trend2h, text_color=(trend2h == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 7, text="4h Trend: " + trend4h, text_color=(trend4h == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 8, text="12h Trend: " + trend12h, text_color=(trend12h == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 9, text="Daily Trend: " + trend1d
Estrutura Geral Completa do Código Atualizado:
pinescript
//@version=5
indicator("Million Moves com Níveis de Entry, SL e TP", overlay=true)
// Parâmetros do indicador
length = input.int(14, title="Comprimento")
src = input(close, title="Fonte")
sl_atr_length = input.int(14, title="Comprimento do ATR para SL")
tp1 = input.float(1.5, title="Multiplicador TP1")
tp2 = input.float(3.0, title="Multiplicador TP2")
tp3 = input.float(4.5, title="Multiplicador TP3")
atr_multiplier = input.float(1.0, title="Multiplicador ATR para SL")
sma_length = input.int(20, title="Comprimento da SMA")
sma_offset = input.float(1.3, title="Deslocamento da SMA")
ema_length = input.int(9, title="Comprimento da EMA")
sma200_length = input.int(200, title="Comprimento da SMA 200")
// Parâmetros do Moving Average Ribbon
ma1_length = input.int(5, title="Comprimento MA1")
ma2_length = input.int(10, title="Comprimento MA2")
ma3_length = input.int(15, title="Comprimento MA3")
ma4_length = input.int(20, title="Comprimento MA4")
ma5_length = input.int(25, title="Comprimento MA5")
// Médias móveis
sma = ta.sma(src, sma_length) + sma_offset
ema = ta.ema(src, ema_length)
sma200 = ta.sma(src, sma200_length)
ma1 = ta.sma(src, ma1_length)
ma2 = ta.sma(src, ma2_length)
ma3 = ta.sma(src, ma3_length)
ma4 = ta.sma(src, ma4_length)
ma5 = ta.sma(src, ma5_length)
chaos_trend = ta.sma(src, 100)
// Cálculo do ATR
atr = ta.atr(sl_atr_length)
// Condições de tendências
trendUp = src > ema and src > sma
trendDown = src < ema and src < sma
// Cores das médias móveis
smaColor = src > sma ? color.green : color.red
emaColor = src > ema ? color.green : color.red
sma200Color = src > sma200 ? color.green : color.red
ma1Color = src > ma1 ? color.new(color.green, 80) : color.new(color.red, 80)
ma2Color = src > ma2 ? color.new(color.green, 80) : color.new(color.red, 80)
ma3Color = src > ma3 ? color.new(color.green, 80) : color.new(color.red, 80)
ma4Color = src > ma4 ? color.new(color.green, 80) : color.new(color.red, 80)
ma5Color = src > ma5 ? color.new(color.green, 80) : color.new(color.red, 80)
chaosColor = src > chaos_trend ? color.green : color.red
// Sinais de compra e venda
buySignal = ta.crossover(src, sma)
sellSignal = ta.crossunder(src, sma)
// Inicialização de níveis e labels
var float entryPrice = na
var float slPrice = na
var float tp1Price = na
var float tp2Price = na
var float tp3Price = na
var bool lastBuySignal = na
var bool lastSellSignal = na
var label entryLabel = na
var label slLabel = na
var label tp1Label = na
var label tp2Label = na
var label tp3Label = na
// Função para criar labels
create_label(label_ref, x, y, label_text, color, style) =>
if (not na(label_ref))
label.delete(label_ref)
label.new(x, y, text=label_text, color=color, textcolor=color.white, style=style, size=size.small)
// Atualiza os níveis quando há um sinal de compra ou venda
if (buySignal or smartBuySignal or plusSmartBuySignal)
entryPrice := close
slPrice := entryPrice - atr * atr_multiplier
tp1Price := entryPrice + atr * tp1
tp2Price := entryPrice + atr * tp2
tp3Price := entryPrice + atr * tp3
create_label(entryLabel, bar_index + 1, entryPrice, "Entry: " + str.tostring(entryPrice), color.blue, label.style_label_down)
create_label(slLabel, bar_index + 1, slPrice, "SL: " + str.tostring(slPrice), color.red, label.style_label_down)
create_label(tp1Label, bar_index + 1, tp1Price, "TP1: " + str.tostring(tp1Price), color.green, label.style_label_down)
create_label(tp2Label, bar_index + 1, tp2Price, "TP2: " + str.tostring(tp2Price), color.green, label.style_label_down)
create_label(tp3Label, bar_index + 1, tp3Price, "TP3: " + str.tostring(tp3Price), color.green, label.style_label_down)
if (sellSignal or smartSellSignal or plusSmartSellSignal)
entryPrice := close
slPrice := entryPrice + atr * atr_multiplier
tp1Price := entryPrice - atr * tp1
tp2Price := entryPrice - atr * tp2
tp3Price := entryPrice - atr * tp3
create_label(entryLabel, bar_index + 1, entryPrice, "Entry: " + str.tostring(entryPrice), color.blue, label.style_label_up)
create_label(slLabel, bar_index + 1, slPrice, "SL: " + str.tostring(slPrice), color.red, label.style_label_up)
create_label(tp1Label, bar_index + 1, tp1Price, "TP1: " + str.tostring(tp1Price), color.green, label.style_label_up)
create_label(tp2Label, bar_index + 1, tp2Price, "TP2: " + str.tostring(tp2Price), color.green, label.style_label_up)
create_label(tp3Label, bar_index + 1, tp3Price, "TP3: " + str.tostring(tp3Price), color.green, label.style_label_up)
// Condições para os sinais inteligentes
smartBuySignal = buySignal and trendUp
smartSellSignal = sellSignal and trendDown
plusSmartBuySignal = smartBuySignal and emaColor == color.green and chaosColor == color.green and trendUp
plusSmartSellSignal = smartSellSignal and emaColor == color.red and chaosColor == color.red and trendDown
// Plota a Média Móvel Simples com deslocamento
plot(sma, color=smaColor, title="SMA", linewidth=2)
// Plota a Média Móvel Exponencial
plot(ema, color=emaColor, title="EMA", linewidth=1)
// Plota a Média Móvel Simples de 200 períodos
plot(sma200, color=sma200Color, title="SMA 200", linewidth=2)
// Plota as Médias Móveis do Moving Average Ribbon
plot(ma1, color=ma1Color, title="MA1", linewidth=1, style=plot.style_stepline)
plot(ma2, color=ma2Color, title="MA2", linewidth=1, style=plot.style_stepline)
plot(ma3, color=ma3Color, title="MA3", linewidth=1, style=plot.style_stepline)
plot(ma4, color=ma4Color, title="MA4", linewidth=1, style=plot.style_stepline)
plot(ma5, color=ma5Color, title="MA5", linewidth=1, style=plot.style_stepline)
// Plota Sinais de Compra e Venda (Contra a Tendência)
plotshape(series=buySignal and not trendUp, location=location.belowbar, color=color.yellow, style=shape.labelup, text="BUY\nAgainst the Trend")
plotshape(series=sellSignal and not trendDown, location=location.abovebar, color=color.orange, style=shape.labeldown, text="SELL\nAgainst the Trend")
// Plota Sinais Inteligentes (Com a Tendência)
plotshape(series=smartBuySignal and trendUp, location=location.belowbar, color=color.green, style=shape.labelup, text="Smart BUY")
plotshape(series=smartSellSignal and trendDown, location=location.abovebar, color=color.red, style=shape.labeldown, text="Smart SELL")
// Plota Sinais de +Smart Buy / +Smart Sell (Com a Tendência e Confirmações)
plotshape(series=plusSmartBuySignal, location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, text="+Smart BUY")
plotshape(series=plusSmartSellSignal, location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text="+Smart SELL")
// Plota o Trend Cloud entre a SMA e a EMA
sma_ema_color = src > ema ? color.new(smaColor, 90) : color.new(emaColor, 90)
sma_plot = plot(sma, title="Trend Cloud SMA", color=color.new(smaColor, 90), linewidth=2, style=plot.style_line)
ema_plot = plot(ema, title="Trend Cloud EMA", color=color.new(emaColor, 90), linewidth=2, style=plot.style_line)
fill(sma_plot, ema_plot, color=sma_ema_color, title="Trend Cloud")
// Identificação dos Order Blocks
order_block_length = input.int(20, title="Comprimento do Order Block")
var float resistance_level = na
var float support_level = na
// Inicializa variáveis persistentes para armazenar os últimos níveis de resistência e suporte
var float last_resistance_level = na
var float last_support_level = na
// Função para calcular a força dos Order Blocks
calcOrderBlockStrength(level, isResistance) =>
distance = isResistance ? level - close : close - level
strength = distance / atr
strength
if (not na(high[1]) and high[1] == ta.highest(high, order_block_length))
resistance_level := high[1]
if (not na(low[1]) and low[1] == ta.lowest(low, order_block_length))
support_level := low[1]
// Plota os Order Blocks com verificação para evitar sobreposição
// Inicializa variáveis persistentes para armazenar os identificadores dos objetos dos Order Blocks
var box resistanceBox = na
var box supportBox = na
var label resistanceLabel = na
var label supportLabel = na
if (not na(resistance_level) and (na(last_resistance_level) or (resistance_level != last_resistance_level)))
// Deleta o Order Block anterior se existir
if (not na(resistanceBox))
box.delete(resistanceBox)
// Deleta a linha anterior se existir
if (not na(resistanceLine))
line.delete(resistanceLine)
// Deleta a label anterior se existir
if (not na(resistanceLabel))
label.delete(resistanceLabel)
// Cria um novo Order Block e armazena seu identificador
resistanceBox := box.new(left=bar_index - order_block_length, top=resistance_level, right=bar_index, bottom=resistance_level - atr * atr_multiplier, border_color=color.red, bgcolor=color.new(color.red, 90))
// Calcula e plota a força do Order Block
resistanceStrength = calcOrderBlockStrength(resistance_level, true)
resistanceLabel := label.new(bar_index, resistance_level, text="Resistência " + (resistanceStrength > 1 ? "Forte" : "Fraca"), color=color.red, textcolor=color.white, style=label.style_label_left, size=size.small)
last_resistance_level := resistance_level
if (not na(support_level) and (na(last_support_level) or (support_level != last_support_level)))
// Deleta o Order Block anterior se existir
if (not na(supportBox))
box.delete(supportBox)
// Deleta a linha anterior se existir
if (not na(supportLine))
line.delete(supportLine)
// Deleta a label anterior se existir
if (not na(supportLabel))
label.delete(supportLabel)
// Cria um novo Order Block e armazena seu identificador
supportBox := box.new(left=bar_index - order_block_length, top=support_level + atr * atr_multiplier, right=bar_index, bottom=support_level, border_color=color.green, bgcolor=color.new(color.green, 90))
// Calcula e plota a força do Order Block
supportStrength = calcOrderBlockStrength(support_level, false)
supportLabel := label.new(bar_index, support_level, text="Suporte " + (supportStrength > 1 ? "Forte" : "Fraco"), color=color.green, textcolor=color.white, style=label.style_label_left, size=size.small)
// Plota linhas verticais para sobrecompra e sobrevenda
overbought = 70
oversold = 30
rsi_length = input.int(14, title="Comprimento do RSI")
rsi = ta.rsi(src, rsi_length)
if (rsi > overbought)
line.new(x1=bar_index, y1=low - atr * 2, x2=bar_index, y2=high + atr * 2, color=color.new(color.green, 80), width=3, style=line.style_solid)
if (rsi < oversold)
line.new(x1=bar_index, y1=low - atr * 2, x2=bar_index, y2=high + atr * 2, color=color.new(color.red, 80), width=3, style=line.style_solid)
// Cor das velas com base na tendência
barcolor(trendUp ? color.green : (trendDown ? color.red : color.purple))
// Dashboard de Tendência
rsiColor = rsi > 50 ? color.green : color.red
trendStrength = (trendUp or trendDown) ? (math.abs(ema - sma) > atr ? "Very High" : (math.abs(ema - sma) > atr * 0.75 ? "High" : (math.abs(ema - sma) > atr * 0.5 ? "Medium" : "Low"))) : "Indecisive"
trendStrengthColor = trendStrength == "Very High" ? color.green : (trendStrength == "High" ? color.blue : (trendStrength == "Medium" ? color.yellow : (trendStrength == "Low" ? color.red : color.gray)))
// Função para determinar tendências em diferentes timeframes
getTrend(timeframe) =>
[t_ema, t_sma] = request.security(syminfo.tickerid, timeframe, [ta.ema(close, ema_length), ta.sma(close, sma_length)])
t_trendUp = t_ema > t_sma
t_trendDown = t_ema < t_sma
t_trendUp ? "Bullish" : (t_trendDown ? "Bearish" : "Indecisive")
trend3m = getTrend("3")
trend5m = getTrend("5")
trend15m = getTrend("15")
trend1h = getTrend("60")
trend2h = getTrend("120")
trend4h = getTrend("240")
trend12h = getTrend("720")
trend1d = getTrend("D")
volatility = atr > sma * 0.02 ? "High" : "Low"
volatilityColor = volatility == "High" ? color.red : color.green
var table dashboard = table.new(position.top_right, 3, 10)
table.cell(dashboard, 0, 0, text="RS
var table dashboard = table.new(position.top_right, 3, 10)
table.cell(dashboard, 0, 0, text="RSI: " + str.tostring(rsi), text_color=rsiColor, text_size=size.small)
table.cell(dashboard, 0, 1, text="Trend Strength: " + trendStrength, text_color=trendStrengthColor, text_size=size.small)
table.cell(dashboard, 0, 2, text="3m Trend: " + trend3m, text_color=(trend3m == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 3, text="5m Trend: " + trend5m, text_color=(trend5m == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 4, text="15m Trend: " + trend15m, text_color=(trend15m == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 5, text="1h Trend: " + trend1h, text_color=(trend1h == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 6, text="2h Trend: " + trend2h, text_color=(trend2h == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 7, text="4h Trend: " + trend4h, text_color=(trend4h == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 8, text="12h Trend: " + trend12h, text_color=(trend12h == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 9, text="Daily Trend: " + trend1d, text_color=(trend1d == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 1, 0, text="Volatility: " + volatility, text_color=volatilityColor, text_size=size.small)
// Alertas
alertcondition(buySignal, title="Sinal de Compra", message="Sinal de Compra!")
alertcondition(sellSignal, title="Sinal de Venda", message="Sinal de Venda!")
alertcondition(smartBuySignal, title="Smart Sinal de Compra", message="Smart Sinal de Compra!")
alertcondition(smartSellSignal, title="Smart Sinal de Venda", message="Smart Sinal de Venda!")
alertcondition(plusSmartBuySignal, title="+Smart Sinal de Compra", message="+Smart Sinal de Compra!")
alertcondition(plusSmartSellSignal, title="+Smart Sinal de Venda", message="+Smart Sinal de Venda!")
// Inicializa variáveis para armazenar os identificadores dos objetos dos Order Blocks
var box resistanceBox = na
var box supportBox = na
if (not na(resistance_level) and (na(last_resistance_level) or (resistance_level != last_resistance_level)))
if (not na(resistanceBox))
box.delete(resistanceBox)
resistanceBox := box.new(left=bar_index - order_block_length, top=resistance_level, right=bar_index, bottom=resistance_level - atr * atr_multiplier, border_color=color.red, bgcolor=color.new(color.red, 90))
last_resistance_level := resistance_level
if (not na(support_level) and (na(last_support_level) or (support_level != last_support_level)))
if (not na(supportBox))
box.delete(supportBox)
supportBox := box.new(left=bar_index - order_block_length, top=support_level + atr * atr_multiplier, right=bar_index, bottom=support_level, border_color=color.green, bgcolor=color.new(color.green, 90))
last_support_level := support_level
Estrutura Final do Código:
pinescript
//@version=5
indicator("Million Moves com Níveis de Entry, SL e TP", overlay=true)
// Parâmetros do indicador
length = input.int(14, title="Comprimento")
src = input(close, title="Fonte")
sl_atr_length = input.int(14, title="Comprimento do ATR para SL")
tp1 = input.float(1.5, title="Multiplicador TP1")
tp2 = input.float(3.0, title="Multiplicador TP2")
tp3 = input.float(4.5, title="Multiplicador TP3")
atr_multiplier = input.float(1.0, title="Multiplicador ATR para SL")
sma_length = input.int(20, title="Comprimento da SMA")
sma_offset = input.float(1.3, title="Deslocamento da SMA")
ema_length = input.int(9, title="Comprimento da EMA")
sma200_length = input.int(200, title="Comprimento da SMA 200")
// Parâmetros do Moving Average Ribbon
ma1_length = input.int(5, title="Comprimento MA1")
ma2_length = input.int(10, title="Comprimento MA2")
ma3_length = input.int(15, title="Comprimento MA3")
ma4_length = input.int(20, title="Comprimento MA4")
ma5_length = input.int(25, title="Comprimento MA5")
// Médias móveis
sma = ta.sma(src, sma_length) + sma_offset
ema = ta.ema(src, ema_length)
sma200 = ta.sma(src, sma200_length)
ma1 = ta.sma(src, ma1_length)
ma2 = ta.sma(src, ma2_length)
ma3 = ta.sma(src, ma3_length)
ma4 = ta.sma(src, ma4_length)
ma5 = ta.sma(src, ma5_length)
chaos_trend = ta.sma(src, 100)
// Cálculo do ATR
atr = ta.atr(sl_atr_length)
// Condições de tendências
trendUp = src > ema and src > sma
trendDown = src < ema and src < sma
// Cores das médias móveis
smaColor = src > sma ? color.green : color.red
emaColor = src > ema ? color.green : color.red
sma200Color = src > sma200 ? color.green : color.red
ma1Color = src > ma1 ? color.new(color.green, 80) : color.new(color.red, 80)
ma2Color = src > ma2 ? color.new(color.green, 80) : color.new(color.red, 80)
ma3Color = src > ma3 ? color.new(color.green, 80) : color.new(color.red, 80)
ma4Color = src > ma4 ? color.new(color.green, 80) : color.new(color.red, 80)
ma5Color = src > ma5 ? color.new(color.green, 80) : color.new(color.red, 80)
chaosColor = src > chaos_trend ? color.green : color.red
// Sinais de compra e venda
buySignal = ta.crossover(src, sma)
sellSignal = ta.crossunder(src, sma)
// Inicialização de níveis e labels
var float entryPrice = na
var float slPrice = na
var float tp1Price = na
var float tp2Price = na
var float tp3Price = na
var bool lastBuySignal = na
var bool lastSellSignal = na
var label entryLabel = na
var label slLabel = na
var label tp1Label = na
var label tp2Label = na
var label tp3Label = na
// Função para criar labels
create_label(label_ref, x, y, label_text, color, style) =>
if (not na(label_ref))
label.delete(label_ref)
label.new(x, y, text=label_text, color=color, textcolor=color.white, style=style, size=size.small)
// Atualiza os níveis quando há um sinal de compra ou venda
if (buySignal or smartBuySignal or plusSmartBuySignal)
entryPrice := close
slPrice := entryPrice - atr * atr_multiplier
tp1Price := entryPrice + atr * tp1
tp2Price := entryPrice + atr * tp2
tp3Price := entryPrice + atr * tp3
create_label(entryLabel, bar_index + 1, entryPrice, "Entry: " + str.tostring(entryPrice), color.blue, label.style_label_down)
create_label(slLabel, bar_index + 1, slPrice, "SL: " + str.tostring(slPrice), color.red, label.style_label_down)
create_label(tp1Label, bar_index + 1, tp1Price, "TP1: " + str.tostring(tp1Price), color.green, label.style_label_down)
create_label(tp2Label, bar_index + 1, tp2Price, "TP2: " + str.tostring(tp2Price), color.green, label.style_label_down)
create_label(tp3Label, bar_index + 1, tp3Price, "TP3: " + str.tostring(tp3Price), color.green, label.style_label_down)
if (sellSignal or smartSellSignal or plusSmartSellSignal)
entryPrice := close
slPrice := entryPrice + atr * atr_multiplier
tp1Price := entryPrice - atr * tp1
tp2Price := entryPrice - atr * tp2
tp3Price := entryPrice - atr * tp3
create_label(entryLabel, bar_index + 1, entryPrice, "Entry: " + str.tostring(entryPrice), color.blue, label.style_label_up)
create_label(slLabel, bar_index + 1, slPrice, "SL: " + str.tostring(slPrice), color.red, label.style_label_up)
create_label(tp1Label, bar_index + 1, tp1Price, "TP1: " + str.tostring(tp1Price), color.green, label.style_label_up)
create_label(tp2Label, bar_index + 1, tp2Price, "TP2: " + str.tostring(tp2Price), color.green, label.style_label_up)
create_label(tp3Label, bar_index + 1, tp3Price, "TP3: " + str.tostring(tp3Price), color.green, label.style_label_up)
// Condições para os sinais inteligentes
smartBuySignal = buySignal and trendUp
smartSellSignal = sellSignal and trendDown
plusSmartBuySignal = smartBuySignal and emaColor == color.green and chaosColor == color.green and trendUp
plusSmartSellSignal = smartSellSignal and emaColor == color.red and chaosColor == color.red and trendDown
// Plota a Média Móvel Simples com deslocamento
plot(sma, color=smaColor, title="SMA", linewidth=2)
// Plota a Média Móvel Exponencial
plot(ema, color=emaColor, title="EMA", linewidth=1)
// Plota a Média Móvel Simples de 200 períodos
plot(sma200, color=sma200Color, title="SMA 200", linewidth=2)
// Plota as Médias Móveis do Moving Average Ribbon
plot(ma1, color=ma1Color, title="MA1", linewidth=1, style=plot.style_stepline)
plot(ma2, color=ma2Color, title="MA2", linewidth=1, style=plot.style_stepline)
plot(ma3, color=ma3Color, title="MA3", linewidth=1, style=plot.style_stepline)
plot(ma4, color=ma4Color, title="MA4", linewidth=1, style=plot.style_stepline)
plot(ma5, color=ma5Color, title="MA5", linewidth=1, style=plot.style_stepline)
// Plota Sinais de Compra e Venda (Contra a Tendência)
plotshape(series=buySignal and not trendUp, location=location.belowbar, color=color.yellow, style=shape.labelup, text="BUY\nAgainst the Trend")
plotshape(series=sellSignal and not trendDown, location=location.abovebar, color=color.orange, style=shape.labeldown, text="SELL\nAgainst the Trend")
// Plota Sinais Inteligentes (Com a Tendência)
plotshape(series=smartBuySignal and trendUp, location=location.belowbar, color=color.green, style=shape.labelup, text="Smart BUY")
plotshape(series=smartSellSignal and trendDown, location=location.abovebar, color=color.red, style=shape.labeldown, text="Smart SELL")
// Plota Sinais de +Smart Buy / +Smart Sell (Com a Tendência e Confirmações)
plotshape(series=plusSmartBuySignal, location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, text="+Smart BUY")
plotshape(series=plusSmartSellSignal, location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text="+Smart SELL")
// Plota o Trend Cloud entre a SMA e a EMA
sma_ema_color = src > ema ? color.new(smaColor, 90) : color.new(emaColor, 90)
sma_plot = plot(sma, title="Trend Cloud SMA", color=color.new(smaColor, 90), linewidth=2, style=plot.style_line)
ema_plot = plot(ema, title="Trend Cloud EMA", color=color.new(emaColor, 90), linewidth=2, style=plot.style_line)
fill(sma_plot, ema_plot, color=sma_ema_color, title="Trend Cloud")
// Identificação dos Order Blocks
order_block_length = input.int(20, title="Comprimento do Order Block")
var float resistance_level = na
var float support_level = na
// Inicializa variáveis persistentes para armazenar os últimos níveis de resistência e suporte
var float last_resistance_level = na
var float last_support_level = na
// Função para calcular a força dos Order Blocks
calcOrderBlockStrength(level, isResistance) =>
distance = isResistance ? level - close : close - level
strength = distance / atr
strength
if (not na(high[1]) and high[1] == ta.highest(high, order_block_length))
resistance_level := high[1]
if (not na(low[1]) and low[1] == ta.lowest(low, order_block_length))
support_level := low[1]
// Plota os Order Blocks com verificação para evitar sobreposição
var box resistanceBox = na
var box supportBox = na
if (not na(resistance_level) and (na(last_resistance_level) or (resistance_level != last_resistance_level)))
if (not na(resistanceBox))
box.delete(resistanceBox)
resistanceBox := box.new(left=bar_index - order_block_length, top=resistance_level, right=bar_index, bottom=resistance_level - atr * atr_multiplier, border_color=color.red, bgcolor=color.new(color.red, 90))
last_resistance_level := resistance_level
if (not na(support_level) and (na(last_support_level) or (support_level != last_support_level)))
if (not na(supportBox))
box.delete(supportBox)
supportBox := box.new(left=bar_index - order_block_length, top=support_level + atr * atr_multiplier, right=bar_index, bottom=support_level, border_color=color.green, bgcolor=color.new(color.green, 90))
last_support_level := support_level
// Plota linhas verticais para sobrecompra e sobrevenda
overbought = 70
oversold = 30
rsi_length = input.int(14, title="Comprimento do RSI")
rsi = ta.rsi(src, rsi_length)
if (rsi > overbought)
line.new(x1=bar_index, y1=low - atr * 2, x2=bar_index, y2=high + atr * 2, color=color.new(color.green, 80), width=3, style=line.style_solid)
if (rsi < oversold)
line.new(x1=bar_index, y1=low - atr * 2, x2=bar_index, y2=high + atr * 2, color=color.new(color.red, 80), width=3, style=line.style_solid)
// Cor das velas com base na tendência
barcolor(trendUp ? color.green : (trendDown ? color.red : color.purple))
// Dashboard de Tendência
rsiColor = rsi > 50 ? color.green : color.red
trendStrength = (trendUp or trendDown) ? (math.abs(ema - sma) > atr ? "Very High" : (math.abs(ema - sma) > atr * 0.75 ? "High" : (math.abs(ema - sma) > atr * 0.5 ? "Medium" : "Low"))) : "Indecisive"
trendStrengthColor = trendStrength == "Very High" ? color.green : (trendStrength == "High" ? color.blue : (trendStrength == "Medium" ? color.yellow : (trendStrength == "Low" ? color.red : color.gray)))
// Função para determinar tendências em diferentes timeframes
getTrend(timeframe) =>
[t_ema, t_sma] = request.security(syminfo.tickerid, timeframe, [ta.ema(close, ema_length), ta.sma(close, sma_length)])
t_trendUp = t_ema > t_sma
t_trendDown = t_ema < t_sma
t_trendUp ? "Bullish" : (t_trendDown ? "Bearish" : "Indecisive")
trend3m = getTrend("3")
trend5m = getTrend("5")
trend15m = getTrend("15")
trend1h = getTrend("60")
trend2h = getTrend("120")
trend4h = getTrend("240")
trend12h = getTrend("720")
trend1d = getTrend("D")
volatility = atr > sma * 0.02 ? "High" : "Low"
volatilityColor = volatility == "High" ? color.red : color.green
var table dashboard = table.new(position.top_right, 3, 10)
table.cell(dashboard, 0, 0, text="RSI: " + str.tostring(rsi), text_color=rsiColor, text_size=size.small)
table.cell(dashboard, 0, 1, text="Trend Strength: " + trendStrength, text_color=trendStrengthColor, text_size=size.small)
table.cell(dashboard, 0, 2, text="3m Trend: " + trend3m, text_color=(trend3m == "Bullish" ? color.green : color.red), text_size=size.small)
table.cell(dashboard, 0, 3, text="5m Trend: " + trend5m, text_color