Script Alligator para IQ Option

Script Alligator para IQ Option

Explicación del Indicador Alligator en Lua

El indicador Alligator es una herramienta popular en el análisis técnico, utilizada para identificar tendencias y momentos de consolidación en los mercados financieros. A continuación, exploramos un script en Lua que implementa este indicador, explicando paso a paso cómo funciona.

Introducción al Script

El script comienza con la declaración del instrumento y algunos parámetros básicos:

instrument { name = "Alligator", icon="indicators:Alligator", overlay = true }

Aquí se define el nombre del indicador, su icono y se especifica que debe superponerse al gráfico de precios.

Configuración de los Parámetros

El Alligator se compone de tres promedios móviles suavizados (Jaws, Teeth y Lips), cada uno con sus propios parámetros. A continuación, se configuran estos parámetros utilizando input_group para cada componente:

Jaws (Mandíbulas)
input_group {
    "front.jaws",
    jaws_period  = input (13, "front.period", input.integer, 1),
    jaws_offset  = input (8, "front.newind.offset", input.integer),
    jaws_color   = input { default = "#56CEFF", type = input.color },
    jaws_width   = input { default = 1, type = input.line_width },
    jaws_visible = input { default = true, type = input.plot_visibility }
}
  • jaws_period: Periodo de tiempo para el cálculo del promedio móvil (13 por defecto).
  • jaws_offset: Desplazamiento del promedio móvil (8 por defecto).
  • jaws_color: Color de la línea (azul claro por defecto).
  • jaws_width: Grosor de la línea (1 por defecto).
  • jaws_visible: Visibilidad del componente (visible por defecto).
Teeth (Dientes)
input_group {
    "front.teeth",
    teeth_period  = input (8, "front.period", input.integer, 1),
    teeth_offset  = input (5, "front.newind.offset", input.integer),
    teeth_color   = input { default = "#FF6C58", type = input.color },
    teeth_width   = input { default = 1, type = input.line_width },
    teeth_visible = input { default = true, type = input.plot_visibility }
}
  • teeth_period: Periodo del promedio móvil (8 por defecto).
  • teeth_offset: Desplazamiento (5 por defecto).
  • teeth_color: Color (rojo por defecto).
  • teeth_width: Grosor (1 por defecto).
  • teeth_visible: Visibilidad (visible por defecto).
Lips (Labios)
input_group {
    "front.lips",
    lips_period  = input (5, "front.period", input.integer, 1),
    lips_offset  = input (3, "front.newind.offset", input.integer),
    lips_color   = input { default = "#25E154", type = input.color },
    lips_width   = input { default = 1, type = input.line_width },
    lips_visible = input { default = true, type = input.plot_visibility }
}
  • lips_period: Periodo del promedio móvil (5 por defecto).
  • lips_offset: Desplazamiento (3 por defecto).
  • lips_color: Color (verde por defecto).
  • lips_width: Grosor (1 por defecto).
  • lips_visible: Visibilidad (visible por defecto).

Fuente de Datos y Función de Promedio

El script permite seleccionar la fuente de datos y el tipo de promedio móvil a utilizar:

source = input (1, "front.ind.source", input.string_selection,  inputs.titles_overlay)
fn     = input (averages.ssma, "front.newind.average", input.string_selection, averages.titles)
  • source: Fuente de datos (1 por defecto).
  • fn: Función de promedio (SSMA por defecto).

Cálculo y Plotting

Finalmente, el script calcula y dibuja cada componente del Alligator si está visible:

Jaws
if jaws_visible then
    jaws = averageFunction(sourceSeries, jaws_period)
    plot (jaws, "front.jaws", jaws_color, jaws_width, jaws_offset)
end
Teeth
if teeth_visible then
    teeth = averageFunction(sourceSeries, teeth_period)
    plot (teeth, "front.teeth", teeth_color, teeth_width, teeth_offset)
end
Lips
if lips_visible then
    lips = averageFunction(sourceSeries, lips_period)
    plot (lips, "front.lips", lips_color, lips_width, lips_offset)
end

Cada bloque comprueba si el componente es visible, calcula el promedio móvil utilizando la función seleccionada y los parámetros definidos, y luego lo dibuja en el gráfico con las características especificadas.

Conclusión

Este script en Lua configura y dibuja el indicador Alligator en un gráfico de precios, permitiendo personalizar los periodos, desplazamientos, colores y grosores de las líneas de Jaws, Teeth y Lips. Es una herramienta poderosa para identificar tendencias en el mercado y puede ser ajustada según las necesidades del usuario.

instrument { name = "Alligator", icon="indicators:Alligator", overlay = true }

input_group {
"front.jaws",
jaws_period = input (13, "front.period", input.integer, 1),
jaws_offset = input (8, "front.newind.offset", input.integer),
jaws_color = input { default = "#56CEFF", type = input.color },
jaws_width = input { default = 1, type = input.line_width },
jaws_visible = input { default = true, type = input.plot_visibility }
}

input_group {
"front.teeth",
teeth_period = input (8, "front.period", input.integer, 1),
teeth_offset = input (5, "front.newind.offset", input.integer),
teeth_color = input { default = "#FF6C58", type = input.color },
teeth_width = input { default = 1, type = input.line_width },
teeth_visible = input { default = true, type = input.plot_visibility }
}

input_group {
"front.lips",
lips_period = input (5, "front.period", input.integer, 1),
lips_offset = input (3, "front.newind.offset", input.integer),
lips_color = input { default = "#25E154", type = input.color },
lips_width = input { default = 1, type = input.line_width },
lips_visible = input { default = true, type = input.plot_visibility }
}

source = input (1, "front.ind.source", input.string_selection, inputs.titles_overlay)
fn = input (averages.ssma, "front.newind.average", input.string_selection, averages.titles)

local sourceSeries = inputs [source]
local averageFunction = averages [fn]

if jaws_visible then
jaws = averageFunction(sourceSeries, jaws_period)
plot (jaws, "front.jaws", jaws_color, jaws_width, jaws_offset)
end

if teeth_visible then
teeth = averageFunction(sourceSeries, teeth_period)
plot (teeth, "front.teeth", teeth_color, teeth_width, teeth_offset)
end

if lips_visible then
lips = averageFunction(sourceSeries, lips_period)
plot (lips, "front.lips", lips_color, lips_width, lips_offset)
end
Carrito de compra
Scroll al inicio
Telegram