OPEN-SOURCE SCRIPT

MAGALHAES NEOWAVE ONDA 3 PRO

155
//version=6
indicator(
title="MAGALHAES NEOWAVE ONDA 3 PRO",
shorttitle="NEOWAVE O3 PRO",
overlay=true,
max_lines_count=500,
max_labels_count=500
)

//==================================================
// 1. MOTOR DA ESTRUTURA
//==================================================
grupoMotor = "1. Motor da Estrutura"

inicioLeitura = input.time(
defval=timestamp("01 Jan 2024 00:00 +0000"),
title="Iniciar/Reiniciar leitura em",
confirm=true,
group=grupoMotor
)

forcaPivot = input.int(
defval=5,
title="Força do pivô",
minval=2,
maxval=30,
group=grupoMotor
)

hipoteseCorrecao = input.string(
defval="Onda 2",
title="Correção analisada",
options=["Onda 2", "Onda 4", "Onda B"],
group=grupoMotor
)

retracaoMinima = input.float(
defval=0.236,
title="Retração mínima para validar",
minval=0.05,
maxval=1.00,
step=0.001,
group=grupoMotor
)

fibIdealMinimo = input.float(
defval=0.382,
title="Início da região Fibonacci válida",
minval=0.05,
maxval=1.00,
step=0.001,
group=grupoMotor
)

fibIdealMaximo = input.float(
defval=0.886,
title="Fim da região Fibonacci válida",
minval=0.05,
maxval=1.50,
step=0.001,
group=grupoMotor
)

invalidarEm100 = input.bool(
defval=true,
title="Invalidar se fechar além de 100%",
group=grupoMotor
)

scoreMinimo = input.int(
defval=80,
title="Índice mínimo de confirmação",
minval=40,
maxval=100,
step=20,
group=grupoMotor
)

//==================================================
// 2. TEMPO NEOWAVE
//==================================================
grupoTempo = "2. Tempo NeoWave"

relacaoMinimaTempo = input.float(
defval=1.00,
title="Tempo mínimo da correção",
minval=0.10,
maxval=5.00,
step=0.05,
group=grupoTempo
)

relacaoIdealInicio = input.float(
defval=1.50,
title="Início da janela temporal ideal",
minval=0.20,
maxval=6.00,
step=0.05,
group=grupoTempo
)

relacaoIdealFim = input.float(
defval=2.00,
title="Fim da janela temporal ideal",
minval=0.30,
maxval=8.00,
step=0.05,
group=grupoTempo
)

//==================================================
// 3. VISUALIZAÇÃO
//==================================================
grupoVisual = "3. Visualização"

mostrarPainel = input.bool(true, "Mostrar painel", group=grupoVisual)
mostrarBase = input.bool(true, "Mostrar movimento direcional", group=grupoVisual)
mostrarCorrecao = input.bool(true, "Mostrar correção", group=grupoVisual)
mostrarFibonacci = input.bool(true, "Mostrar Fibonacci", group=grupoVisual)
mostrarAlvos = input.bool(true, "Mostrar alvos", group=grupoVisual)
mostrarSinal = input.bool(true, "Mostrar sinal da próxima onda", group=grupoVisual)
mostrarFundo = input.bool(false, "Colorir fundo temporal", group=grupoVisual)

//==================================================
// 4. NÍVEIS
//==================================================
grupoNiveis = "4. Níveis"

usar236 = input.bool(true, "23,6%", group=grupoNiveis)
usar382 = input.bool(true, "38,2%", group=grupoNiveis)
usar500 = input.bool(true, "50,0%", group=grupoNiveis)
usar618 = input.bool(true, "61,8%", group=grupoNiveis)
usar705 = input.bool(true, "70,5%", group=grupoNiveis)
usar786 = input.bool(true, "78,6%", group=grupoNiveis)
usar810 = input.bool(true, "81,0%", group=grupoNiveis)
usar854 = input.bool(true, "85,4%", group=grupoNiveis)
usar886 = input.bool(true, "88,6%", group=grupoNiveis)
usar100 = input.bool(true, "100,0%", group=grupoNiveis)

//==================================================
// 5. CORES
//==================================================
grupoCores = "5. Cores"

corAlta = input.color(color.lime, "Direcional de alta", group=grupoCores)
corBaixa = input.color(color.red, "Direcional de baixa", group=grupoCores)
corCorrecao = input.color(color.orange, "Correção", group=grupoCores)
corFibo = input.color(color.aqua, "Fibonacci", group=grupoCores)
corIdeal = input.color(color.yellow, "Janela temporal ideal", group=grupoCores)
corConfirmacao = input.color(color.green, "Próxima onda confirmada", group=grupoCores)
corAlvo = input.color(color.fuchsia, "Alvos", group=grupoCores)

//==================================================
// 6. FUNÇÕES
//==================================================
f_tempo(float minutos) =>
string texto = "AGUARDANDO"

if not na(minutos)
int dias = int(math.floor(minutos / 1440.0))
int horas = int(math.floor((minutos % 1440.0) / 60.0))
int mins = int(math.floor(minutos % 60.0))

if dias > 0
texto := str.tostring(dias) + "d " + str.tostring(horas) + "h " + str.tostring(mins) + "m"
else if horas > 0
texto := str.tostring(horas) + "h " + str.tostring(mins) + "m"
else
texto := str.tostring(mins) + "m"

texto

f_percentual(float valor) =>
na(valor) ? "AGUARDANDO" : str.tostring(valor * 100.0, "#.##") + "%"

f_relacao(float valor) =>
na(valor) ? "AGUARDANDO" : str.tostring(valor, "#.##") + "x"

f_preco(float valor) =>
na(valor) ? "-" : str.tostring(valor, format.mintick)

f_simNao(bool condicao) =>
condicao ? "SIM" : "NÃO"

f_nivelRetracao(float inicio, float fim, float percentual) =>
fim - ((fim - inicio) * percentual)

f_nomeProximaOnda(string tipoCorrecao) =>
string nome = "ONDA C"

if tipoCorrecao == "Onda 2"
nome := "ONDA 3"
else if tipoCorrecao == "Onda 4"
nome := "ONDA 5"

nome

f_direcaoTexto(int direcao) =>
string texto = "AGUARDANDO"

if direcao == 1
texto := "ALTA"
else if direcao == -1
texto := "BAIXA"

texto

//==================================================
// 7. PIVÔS CONFIRMADOS
//==================================================
float pivotTopo = ta.pivothigh(high, forcaPivot, forcaPivot)
float pivotFundo = ta.pivotlow(low, forcaPivot, forcaPivot)

float novoPivotPreco = na
int novoPivotBar = na
int novoPivotTempo = na
int novoPivotTipo = 0

if not na(pivotTopo) and na(pivotFundo)
novoPivotPreco := pivotTopo
novoPivotBar := bar_index - forcaPivot
novoPivotTempo := time[forcaPivot]
novoPivotTipo := 1

else if not na(pivotFundo) and na(pivotTopo)
novoPivotPreco := pivotFundo
novoPivotBar := bar_index - forcaPivot
novoPivotTempo := time[forcaPivot]
novoPivotTipo := -1

//==================================================
// 8. ESTADOS
//==================================================
// 0 = procurando movimento direcional
// 1 = correção ativa
// 2 = próxima onda iniciada
var int estado = 0

//==================================================
// 9. MEMÓRIA DO ÚLTIMO PIVÔ
//==================================================
var float ultimoPivotPreco = na
var int ultimoPivotBar = na
var int ultimoPivotTempo = na
var int ultimoPivotTipo = 0

//==================================================
// 10. MOVIMENTO DIRECIONAL TRAVADO
//==================================================
var float baseInicioPreco = na
var float baseFimPreco = na

var int baseInicioBar = na
var int baseFimBar = na

var int baseInicioTempo = na
var int baseFimTempo = na

var int direcaoBase = 0

var float tempoBase = na
var float amplitudeBase = na

//==================================================
// 11. CORREÇÃO
//==================================================
var float extremoCorrecao = na
var int extremoCorrecaoBar = na
var int extremoCorrecaoTempo = na

var float retracaoMaxima = na
var bool correcaoValidada = false

var int finalCorrecaoTempo = na
var int confirmacaoBar = na
var float confirmacaoPreco = na

//==================================================
// 12. OBJETOS
//==================================================
var line linhaBase = na
var line linhaCorrecao = na
var line linhaRetomada = na

var label labelInicio = na
var label labelFim = na
var label labelCorrecao = na
var label labelConfirmacao = na

var line[] linhasFibo = array.new_line()
var label[] labelsFibo = array.new_label()

var line[] linhasAlvo = array.new_line()
var label[] labelsAlvo = array.new_label()

//==================================================
// 13. LIMPEZA DOS NÍVEIS
//==================================================
f_limparFibo() =>
int totalLinhas = array.size(linhasFibo)

if totalLinhas > 0
for i = 0 to totalLinhas - 1
line.delete(array.get(linhasFibo, i))

int totalLabels = array.size(labelsFibo)

if totalLabels > 0
for i = 0 to totalLabels - 1
label.delete(array.get(labelsFibo, i))

array.clear(linhasFibo)
array.clear(labelsFibo)

f_limparAlvos() =>
int totalLinhas = array.size(linhasAlvo)

if totalLinhas > 0
for i = 0 to totalLinhas - 1
line.delete(array.get(linhasAlvo, i))

int totalLabels = array.size(labelsAlvo)

if totalLabels > 0
for i = 0 to totalLabels - 1
label.delete(array.get(labelsAlvo, i))

array.clear(linhasAlvo)
array.clear(labelsAlvo)

//==================================================
// 14. DESENHO DE FIBONACCI
//==================================================
f_desenharFibo(float precoNivel, string nome, bool habilitado) =>
if habilitado and mostrarFibonacci and not na(precoNivel) and not na(baseFimBar)
line novaLinha = line.new(
x1=baseFimBar,
y1=precoNivel,
x2=bar_index + 25,
y2=precoNivel,
xloc=xloc.bar_index,
extend=extend.right,
color=corFibo,
style=line.style_dashed,
width=1
)

label novoLabel = label.new(
x=bar_index,
y=precoNivel,
text=nome + " " + f_preco(precoNivel),
xloc=xloc.bar_index,
yloc=yloc.price,
style=label.style_label_left,
color=color.new(corFibo, 78),
textcolor=corFibo,
size=size.tiny
)

array.push(linhasFibo, novaLinha)
array.push(labelsFibo, novoLabel)

//==================================================
// 15. DESENHO DOS ALVOS
//==================================================
f_desenharAlvo(float precoAlvo, string nome) =>
if mostrarAlvos and not na(precoAlvo) and not na(confirmacaoBar)
line novaLinha = line.new(
x1=confirmacaoBar,
y1=precoAlvo,
x2=bar_index + 30,
y2=precoAlvo,
xloc=xloc.bar_index,
extend=extend.right,
color=corAlvo,
style=line.style_dotted,
width=2
)

label novoLabel = label.new(
x=bar_index,
y=precoAlvo,
text=nome + " " + f_preco(precoAlvo),
xloc=xloc.bar_index,
yloc=yloc.price,
style=label.style_label_left,
color=color.new(corAlvo, 75),
textcolor=corAlvo,
size=size.small
)

array.push(linhasAlvo, novaLinha)
array.push(labelsAlvo, novoLabel)

//==================================================
// 16. IDENTIFICAÇÃO DO MOVIMENTO DIRECIONAL
//==================================================
bool leituraAtiva = time >= inicioLeitura

if leituraAtiva and estado == 0 and novoPivotTipo != 0 and novoPivotTempo >= inicioLeitura
if na(ultimoPivotPreco)
ultimoPivotPreco := novoPivotPreco
ultimoPivotBar := novoPivotBar
ultimoPivotTempo := novoPivotTempo
ultimoPivotTipo := novoPivotTipo

else if novoPivotTipo == ultimoPivotTipo
bool pivotMaisExtremo = novoPivotTipo == 1 ? novoPivotPreco > ultimoPivotPreco : novoPivotPreco < ultimoPivotPreco

if pivotMaisExtremo
ultimoPivotPreco := novoPivotPreco
ultimoPivotBar := novoPivotBar
ultimoPivotTempo := novoPivotTempo

else
baseInicioPreco := ultimoPivotPreco
baseInicioBar := ultimoPivotBar
baseInicioTempo := ultimoPivotTempo

baseFimPreco := novoPivotPreco
baseFimBar := novoPivotBar
baseFimTempo := novoPivotTempo

direcaoBase := baseFimPreco > baseInicioPreco ? 1 : -1
tempoBase := math.abs(baseFimTempo - baseInicioTempo) / 60000.0
amplitudeBase := math.abs(baseFimPreco - baseInicioPreco)

extremoCorrecao := baseFimPreco
extremoCorrecaoBar := baseFimBar
extremoCorrecaoTempo := baseFimTempo

retracaoMaxima := 0.0
correcaoValidada := false

finalCorrecaoTempo := na
confirmacaoBar := na
confirmacaoPreco := na

estado := 1

ultimoPivotPreco := novoPivotPreco
ultimoPivotBar := novoPivotBar
ultimoPivotTempo := novoPivotTempo
ultimoPivotTipo := novoPivotTipo

//==================================================
// 17. MEDIÇÃO DA CORREÇÃO
//==================================================
float retracaoAtual = na

if estado == 1 and not na(amplitudeBase) and amplitudeBase > 0
if direcaoBase == 1
if low < extremoCorrecao
extremoCorrecao := low
extremoCorrecaoBar := bar_index
extremoCorrecaoTempo := time

retracaoAtual := math.max(0.0, (baseFimPreco - close) / amplitudeBase)
retracaoMaxima := math.max(0.0, (baseFimPreco - extremoCorrecao) / amplitudeBase)

else if direcaoBase == -1
if high > extremoCorrecao
extremoCorrecao := high
extremoCorrecaoBar := bar_index
extremoCorrecaoTempo := time

retracaoAtual := math.max(0.0, (close - baseFimPreco) / amplitudeBase)
retracaoMaxima := math.max(0.0, (extremoCorrecao - baseFimPreco) / amplitudeBase)

correcaoValidada := retracaoMaxima >= retracaoMinima

//==================================================
// 18. TEMPO DA CORREÇÃO
//==================================================
int tempoAgora = barstate.isrealtime ? timenow : time_close
float tempoCorrecao = na

if estado == 1 and not na(baseFimTempo)
tempoCorrecao := math.max(0.0, (tempoAgora - baseFimTempo) / 60000.0)

else if estado == 2
if not na(baseFimTempo) and not na(finalCorrecaoTempo)
tempoCorrecao := math.max(0.0, (finalCorrecaoTempo - baseFimTempo) / 60000.0)

float relacaoTemporal = na

if not na(tempoBase) and tempoBase > 0 and not na(tempoCorrecao)
relacaoTemporal := tempoCorrecao / tempoBase

float tempoMinimo = na
float inicioJanela = na
float fimJanela = na

if not na(tempoBase)
tempoMinimo := tempoBase * relacaoMinimaTempo
inicioJanela := tempoBase * relacaoIdealInicio
fimJanela := tempoBase * relacaoIdealFim

float faltamMinimo = na

if not na(tempoCorrecao) and not na(tempoMinimo)
if tempoCorrecao < tempoMinimo
faltamMinimo := tempoMinimo - tempoCorrecao

float faltamJanela = na

if not na(tempoCorrecao) and not na(inicioJanela)
if tempoCorrecao < inicioJanela
faltamJanela := inicioJanela - tempoCorrecao

bool tempoValido = not na(relacaoTemporal) and relacaoTemporal >= relacaoMinimaTempo
bool janelaIdeal = not na(relacaoTemporal) and relacaoTemporal >= relacaoIdealInicio and relacaoTemporal <= relacaoIdealFim
bool tempoExcedido = not na(relacaoTemporal) and relacaoTemporal > relacaoIdealFim
bool fibValida = not na(retracaoMaxima) and retracaoMaxima >= fibIdealMinimo and retracaoMaxima <= fibIdealMaximo

//==================================================
// 19. INVALIDAÇÃO
//==================================================
bool estruturaInvalidada = false

if estado == 1 and invalidarEm100 and not na(baseInicioPreco)
if direcaoBase == 1
estruturaInvalidada := close <= baseInicioPreco
else if direcaoBase == -1
estruturaInvalidada := close >= baseInicioPreco

if estruturaInvalidada
estado := 0

ultimoPivotPreco := na
ultimoPivotBar := na
ultimoPivotTempo := na
ultimoPivotTipo := 0

baseInicioPreco := na
baseFimPreco := na
baseInicioBar := na
baseFimBar := na
baseInicioTempo := na
baseFimTempo := na

direcaoBase := 0
tempoBase := na
amplitudeBase := na

extremoCorrecao := na
extremoCorrecaoBar := na
extremoCorrecaoTempo := na

retracaoMaxima := na
correcaoValidada := false

finalCorrecaoTempo := na
confirmacaoBar := na
confirmacaoPreco := na

if not na(linhaBase)
line.delete(linhaBase)

if not na(linhaCorrecao)
line.delete(linhaCorrecao)

if not na(linhaRetomada)
line.delete(linhaRetomada)

linhaBase := na
linhaCorrecao := na
linhaRetomada := na

if not na(labelInicio)
label.delete(labelInicio)

if not na(labelFim)
label.delete(labelFim)

if not na(labelCorrecao)
label.delete(labelCorrecao)

if not na(labelConfirmacao)
label.delete(labelConfirmacao)

labelInicio := na
labelFim := na
labelCorrecao := na
labelConfirmacao := na

f_limparFibo()
f_limparAlvos()

//==================================================
// 20. CONFIRMAÇÃO DA PRÓXIMA ONDA
//==================================================
bool retomadaAlta = estado == 1 and direcaoBase == 1 and correcaoValidada and close > baseFimPreco
bool retomadaBaixa = estado == 1 and direcaoBase == -1 and correcaoValidada and close < baseFimPreco
bool retomadaConfirmada = barstate.isconfirmed and (retomadaAlta or retomadaBaixa)

if retomadaConfirmada
estado := 2
finalCorrecaoTempo := time_close
confirmacaoBar := bar_index
confirmacaoPreco := close

//==================================================
// 21. ÍNDICE NEOWAVE
//==================================================
int indiceNeoWave = 0

if not na(baseFimPreco)
indiceNeoWave += 20

if correcaoValidada
indiceNeoWave += 20

if tempoValido
indiceNeoWave += 20

if fibValida
indiceNeoWave += 20

if estado == 2
indiceNeoWave += 20

bool proximaOndaConfirmada = estado == 2 and indiceNeoWave >= scoreMinimo

//==================================================
// 22. TEXTOS OPERACIONAIS
//==================================================
string nomeProximaOnda = f_nomeProximaOnda(hipoteseCorrecao)
string proximaOndaDirecao = "AGUARDANDO"

if direcaoBase == 1
proximaOndaDirecao := nomeProximaOnda + " DE ALTA"
else if direcaoBase == -1
proximaOndaDirecao := nomeProximaOnda + " DE BAIXA"

string faseTexto = "PROCURANDO DIRECIONAL"
string ondaAtualTexto = "AGUARDANDO"
string estagioTexto = "AGUARDANDO"
string acaoTexto = "AGUARDAR"
string sinalTexto = "SEM SINAL"

if estado == 1
faseTexto := "CORREÇÃO ATIVA"
ondaAtualTexto := str.upper(hipoteseCorrecao)

if not correcaoValidada
estagioTexto := "CORREÇÃO NÃO VALIDADA"
acaoTexto := "AGUARDAR RETRAÇÃO MÍNIMA"

else if not tempoValido
estagioTexto := "CORREÇÃO JOVEM"
acaoTexto := "AGUARDAR MATURIDADE"

else if janelaIdeal and fibValida
estagioTexto := "JANELA DE FINAL DA " + str.upper(hipoteseCorrecao)
acaoTexto := "AGUARDAR RETOMADA DE " + f_direcaoTexto(direcaoBase)

else if tempoExcedido
estagioTexto := "CORREÇÃO COMPLEXA"
acaoTexto := "REAVALIAR CONTAGEM"

else
estagioTexto := "CORREÇÃO MADURA"
acaoTexto := "MONITORAR FINAL DA " + str.upper(hipoteseCorrecao)

else if estado == 2
faseTexto := "EXPANSÃO INICIADA"
ondaAtualTexto := proximaOndaDirecao

if proximaOndaConfirmada
estagioTexto := proximaOndaDirecao + " CONFIRMADA"

if direcaoBase == 1
sinalTexto := "SINAL DE ALTA"
acaoTexto := "ACOMPANHAR EXPANSÃO DE ALTA"
else
sinalTexto := "SINAL DE BAIXA"
acaoTexto := "ACOMPANHAR EXPANSÃO DE BAIXA"

else
estagioTexto := "RETOMADA CONFIRMADA"
acaoTexto := "ÍNDICE ABAIXO DO MÍNIMO"

//==================================================
// 23. STOP E ALVOS
//==================================================
float stopTecnico = estado == 2 ? extremoCorrecao : na

float alvo100 = na
float alvo1618 = na
float alvo2618 = na

if estado == 2 and not na(extremoCorrecao) and not na(amplitudeBase)
alvo100 := extremoCorrecao + direcaoBase * amplitudeBase
alvo1618 := extremoCorrecao + direcaoBase * amplitudeBase * 1.618
alvo2618 := extremoCorrecao + direcaoBase * amplitudeBase * 2.618

//==================================================
// 24. DESENHO DO DIRECIONAL
//==================================================
if not na(baseInicioBar) and not na(baseFimBar)
color corDirecional = direcaoBase == 1 ? corAlta : corBaixa

if mostrarBase
if na(linhaBase)
linhaBase := line.new(
x1=baseInicioBar,
y1=baseInicioPreco,
x2=baseFimBar,
y2=baseFimPreco,
xloc=xloc.bar_index,
color=corDirecional,
width=3
)
else
line.set_xy1(linhaBase, baseInicioBar, baseInicioPreco)
line.set_xy2(linhaBase, baseFimBar, baseFimPreco)
line.set_color(linhaBase, corDirecional)

if na(labelInicio)
labelInicio := label.new(
x=baseInicioBar,
y=baseInicioPreco,
text="INÍCIO DIRECIONAL",
xloc=xloc.bar_index,
yloc=yloc.price,
style=direcaoBase == 1 ? label.style_label_up : label.style_label_down,
color=corDirecional,
textcolor=color.white,
size=size.small
)

if na(labelFim)
labelFim := label.new(
x=baseFimBar,
y=baseFimPreco,
text="FIM DIRECIONAL\n" + f_tempo(tempoBase),
xloc=xloc.bar_index,
yloc=yloc.price,
style=direcaoBase == 1 ? label.style_label_down : label.style_label_up,
color=corDirecional,
textcolor=color.white,
size=size.small
)

//==================================================
// 25. DESENHO DA CORREÇÃO
//==================================================
if mostrarCorrecao and estado >= 1 and not na(baseFimBar) and not na(extremoCorrecaoBar)
if na(linhaCorrecao)
linhaCorrecao := line.new(
x1=baseFimBar,
y1=baseFimPreco,
x2=extremoCorrecaoBar,
y2=extremoCorrecao,
xloc=xloc.bar_index,
color=corCorrecao,
width=2
)
else
line.set_xy1(linhaCorrecao, baseFimBar, baseFimPreco)
line.set_xy2(linhaCorrecao, extremoCorrecaoBar, extremoCorrecao)
line.set_color(linhaCorrecao, corCorrecao)

string textoCorrecao = str.upper(hipoteseCorrecao) + "\n" + f_tempo(tempoCorrecao)

if na(labelCorrecao)
labelCorrecao := label.new(
x=extremoCorrecaoBar,
y=extremoCorrecao,
text=textoCorrecao,
xloc=xloc.bar_index,
yloc=yloc.price,
style=direcaoBase == 1 ? label.style_label_up : label.style_label_down,
color=corCorrecao,
textcolor=color.white,
size=size.small
)
else
label.set_xy(labelCorrecao, extremoCorrecaoBar, extremoCorrecao)
label.set_text(labelCorrecao, textoCorrecao)

//==================================================
// 26. SINAL DA PRÓXIMA ONDA
//==================================================
if estado == 2
if not na(confirmacaoBar)
if na(linhaRetomada)
linhaRetomada := line.new(
x1=extremoCorrecaoBar,
y1=extremoCorrecao,
x2=confirmacaoBar,
y2=confirmacaoPreco,
xloc=xloc.bar_index,
color=corConfirmacao,
width=3
)
else
line.set_xy1(linhaRetomada, extremoCorrecaoBar, extremoCorrecao)
line.set_xy2(linhaRetomada, confirmacaoBar, confirmacaoPreco)
line.set_color(linhaRetomada, corConfirmacao)

string textoConfirmacao = "RETOMADA CONFIRMADA\n" + str.tostring(indiceNeoWave) + "/100"

if proximaOndaConfirmada
textoConfirmacao := proximaOndaDirecao + "\nCONFIRMADA\n" + str.tostring(indiceNeoWave) + "/100"

if mostrarSinal
if na(labelConfirmacao)
labelConfirmacao := label.new(
x=confirmacaoBar,
y=direcaoBase == 1 ? low : high,
text=textoConfirmacao,
xloc=xloc.bar_index,
yloc=yloc.price,
style=direcaoBase == 1 ? label.style_label_up : label.style_label_down,
color=proximaOndaConfirmada ? corConfirmacao : color.orange,
textcolor=color.white,
size=size.normal
)
else
label.set_xy(labelConfirmacao, confirmacaoBar, direcaoBase == 1 ? low : high)
label.set_text(labelConfirmacao, textoConfirmacao)
label.set_color(labelConfirmacao, proximaOndaConfirmada ? corConfirmacao : color.orange)

//==================================================
// 27. FIBONACCI
//==================================================
if barstate.islast
f_limparFibo()

if estado >= 1 and not na(baseInicioPreco) and not na(baseFimPreco)
f_desenharFibo(f_nivelRetracao(baseInicioPreco, baseFimPreco, 0.236), "23,6%", usar236)
f_desenharFibo(f_nivelRetracao(baseInicioPreco, baseFimPreco, 0.382), "38,2%", usar382)
f_desenharFibo(f_nivelRetracao(baseInicioPreco, baseFimPreco, 0.500), "50,0%", usar500)
f_desenharFibo(f_nivelRetracao(baseInicioPreco, baseFimPreco, 0.618), "61,8%", usar618)
f_desenharFibo(f_nivelRetracao(baseInicioPreco, baseFimPreco, 0.705), "70,5%", usar705)
f_desenharFibo(f_nivelRetracao(baseInicioPreco, baseFimPreco, 0.786), "78,6%", usar786)
f_desenharFibo(f_nivelRetracao(baseInicioPreco, baseFimPreco, 0.810), "81,0%", usar810)
f_desenharFibo(f_nivelRetracao(baseInicioPreco, baseFimPreco, 0.854), "85,4%", usar854)
f_desenharFibo(f_nivelRetracao(baseInicioPreco, baseFimPreco, 0.886), "88,6%", usar886)
f_desenharFibo(f_nivelRetracao(baseInicioPreco, baseFimPreco, 1.000), "100,0%", usar100)

//==================================================
// 28. ALVOS
//==================================================
if barstate.islast
f_limparAlvos()

if proximaOndaConfirmada
f_desenharAlvo(alvo100, "ALVO 1 — 100%")
f_desenharAlvo(alvo1618, "ALVO 2 — 161,8%")
f_desenharAlvo(alvo2618, "ALVO 3 — 261,8%")

//==================================================
// 29. FUNDO
//==================================================
color corFundo = na

if mostrarFundo and estado == 1 and janelaIdeal
corFundo := color.new(corIdeal, 88)
else if mostrarFundo and proximaOndaConfirmada
corFundo := color.new(corConfirmacao, 90)

bgcolor(corFundo)

//==================================================
// 30. PAINEL
//==================================================
var table painel = table.new(position.top_right, 2, 23, border_width=1)

if mostrarPainel and barstate.islast
color corDirecao = color.gray
color corEstado = corCorrecao

if direcaoBase == 1
corDirecao := corAlta
else if direcaoBase == -1
corDirecao := corBaixa

if proximaOndaConfirmada
corEstado := corConfirmacao
else if janelaIdeal
corEstado := corIdeal
else if tempoExcedido
corEstado := color.fuchsia

string movimentoBaseTexto = "AGUARDANDO"

if direcaoBase == 1
movimentoBaseTexto := "DIRECIONAL DE ALTA"
else if direcaoBase == -1
movimentoBaseTexto := "DIRECIONAL DE BAIXA"

string textoJanela = "-"

if janelaIdeal
textoJanela := "JANELA ATIVA"
else if tempoExcedido
textoJanela := "JANELA EXCEDIDA"
else if not na(faltamJanela)
textoJanela := f_tempo(faltamJanela)

table.cell(painel, 0, 0, "MAGALHAES", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 0, "NEOWAVE ONDA 3 PRO", bgcolor=color.black, text_color=color.white)

table.cell(painel, 0, 1, "Fase", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 1, faseTexto, bgcolor=corEstado, text_color=color.white)

table.cell(painel, 0, 2, "Movimento Base", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 2, movimentoBaseTexto, bgcolor=corDirecao, text_color=color.white)

table.cell(painel, 0, 3, "Onda Atual", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 3, ondaAtualTexto, bgcolor=corEstado, text_color=color.white)

table.cell(painel, 0, 4, "Estágio", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 4, estagioTexto, bgcolor=corEstado, text_color=color.white)

table.cell(painel, 0, 5, "Tempo Direcional", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 5, f_tempo(tempoBase), bgcolor=color.gray, text_color=color.white)

table.cell(painel, 0, 6, "Tempo Correção", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 6, f_tempo(tempoCorrecao), bgcolor=color.gray, text_color=color.white)

table.cell(painel, 0, 7, "Relação Temporal", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 7, f_relacao(relacaoTemporal), bgcolor=corEstado, text_color=color.white)

table.cell(painel, 0, 8, "Tempo Mínimo", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 8, f_tempo(tempoMinimo), bgcolor=color.gray, text_color=color.white)

table.cell(painel, 0, 9, "Faltam Mínimo", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 9, not na(faltamMinimo) ? f_tempo(faltamMinimo) : "CUMPRIDO", bgcolor=tempoValido ? color.green : color.gray, text_color=color.white)

table.cell(painel, 0, 10, "Janela Ideal", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 10, f_tempo(inicioJanela) + " até " + f_tempo(fimJanela), bgcolor=color.gray, text_color=color.white)

table.cell(painel, 0, 11, "Faltam Janela", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 11, textoJanela, bgcolor=corEstado, text_color=color.white)

table.cell(painel, 0, 12, "Retração Atual", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 12, f_percentual(retracaoAtual), bgcolor=color.gray, text_color=color.white)

table.cell(painel, 0, 13, "Retração Máxima", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 13, f_percentual(retracaoMaxima), bgcolor=color.gray, text_color=color.white)

table.cell(painel, 0, 14, "Tempo Válido", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 14, f_simNao(tempoValido), bgcolor=tempoValido ? color.green : color.gray, text_color=color.white)

table.cell(painel, 0, 15, "Fib Válida", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 15, f_simNao(fibValida), bgcolor=fibValida ? color.green : color.gray, text_color=color.white)

table.cell(painel, 0, 16, "Correção Completa", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 16, estado == 2 ? "SIM" : "NÃO", bgcolor=estado == 2 ? color.green : color.gray, text_color=color.white)

table.cell(painel, 0, 17, "Rompimento", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 17, estado == 2 ? "CONFIRMADO" : "AGUARDANDO", bgcolor=estado == 2 ? color.green : color.gray, text_color=color.white)

table.cell(painel, 0, 18, "Índice NeoWave", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 18, str.tostring(indiceNeoWave) + " / 100", bgcolor=indiceNeoWave >= scoreMinimo ? color.green : color.orange, text_color=color.white)

table.cell(painel, 0, 19, "Sinal", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 19, sinalTexto, bgcolor=proximaOndaConfirmada ? corDirecao : color.gray, text_color=color.white)

table.cell(painel, 0, 20, "Stop Técnico", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 20, f_preco(stopTecnico), bgcolor=color.red, text_color=color.white)

table.cell(painel, 0, 21, "Alvos", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 21, "100%: " + f_preco(alvo100) + "\n161,8%: " + f_preco(alvo1618) + "\n261,8%: " + f_preco(alvo2618), bgcolor=corAlvo, text_color=color.white)

table.cell(painel, 0, 22, "Estado / Ação", bgcolor=color.black, text_color=color.white)
table.cell(painel, 1, 22, estagioTexto + "\n" + acaoTexto, bgcolor=corEstado, text_color=color.white)

//==================================================
// 31. ALERTAS
//==================================================
alertcondition(
correcaoValidada and not correcaoValidada[1],
title="NeoWave — Correção validada",
message="A correção atingiu a retração mínima."
)

alertcondition(
tempoValido and not tempoValido[1],
title="NeoWave — Tempo mínimo cumprido",
message="A correção cumpriu o tempo mínimo."
)

alertcondition(
janelaIdeal and not janelaIdeal[1],
title="NeoWave — Janela temporal ativa",
message="A correção entrou na janela temporal ideal."
)

alertcondition(
retomadaConfirmada,
title="NeoWave — Retomada confirmada",
message="A correção terminou e a direção original foi retomada."
)

alertcondition(
proximaOndaConfirmada and not proximaOndaConfirmada[1],
title="NeoWave — Próxima onda confirmada",
message="A próxima onda foi confirmada pelo motor NeoWave."
)

alertcondition(
estruturaInvalidada,
title="NeoWave — Estrutura invalidada",
message="A correção fechou além da origem do movimento direcional."
)

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.