All tools

AI indicator generator (MQL5 and Pine Script)

Describe an indicator or strategy's logic in plain language and the AI generates ready-to-compile MQL5 (for MetaTrader) or Pine Script (for TradingView) code, with its explanation, parameters and install instructions. You compile and use the code under your own responsibility; always test it on Demo before going live.

How it works

  • · You describe the logic you want — 'arrows when two moving averages cross', for example.
  • · The AI generates the MQL5 or Pine Script code, with an explanation, parameters and how to install it.
  • · You copy or download it and compile it in MetaEditor or open it in TradingView. With an account you can iterate it with AI.

A real example

Example

Sample MQL5 indicator: arrows on a moving-average cross. With your account you generate it your way.

MQL5v1SMA Cross Arrows

What this indicator does

Dibuja una flecha de compra cuando la media rápida cruza por encima de la lenta, y una de venta cuando la cruza por debajo. Es un indicador visual: no abre ni cierra operaciones, solo marca los cruces en el gráfico.

Code

//+------------------------------------------------------------------+
//|                                          SMA_Cross_Arrows.mq5     |
//|  Flechas de compra/venta en el cruce de dos medias simples.      |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2

input int FastPeriod = 10;   // Periodo de la media rápida
input int SlowPeriod = 50;   // Periodo de la media lenta

double BuyBuffer[];
double SellBuffer[];
int    fastHandle, slowHandle;

int OnInit()
{
   SetIndexBuffer(0, BuyBuffer, INDICATOR_DATA);
   SetIndexBuffer(1, SellBuffer, INDICATOR_DATA);
   PlotIndexSetInteger(0, PLOT_ARROW, 233); // flecha arriba
   PlotIndexSetInteger(1, PLOT_ARROW, 234); // flecha abajo
   fastHandle = iMA(_Symbol, _Period, FastPeriod, 0, MODE_SMA, PRICE_CLOSE);
   slowHandle = iMA(_Symbol, _Period, SlowPeriod, 0, MODE_SMA, PRICE_CLOSE);
   return(fastHandle == INVALID_HANDLE || slowHandle == INVALID_HANDLE ? INIT_FAILED : INIT_SUCCEEDED);
}

int OnCalculate(const int rates_total, const int prev_calculated, const int begin,
                const double &price[])
{
   double fast[], slow[];
   int toCopy = rates_total - prev_calculated + 1;
   if(CopyBuffer(fastHandle, 0, 0, toCopy, fast) <= 0) return(prev_calculated);
   if(CopyBuffer(slowHandle, 0, 0, toCopy, slow) <= 0) return(prev_calculated);

   int start = (prev_calculated > 1) ? prev_calculated - 1 : 1;
   for(int i = start; i < rates_total; i++)
   {
      BuyBuffer[i]  = EMPTY_VALUE;
      SellBuffer[i] = EMPTY_VALUE;
      if(fast[i-1] <= slow[i-1] && fast[i] > slow[i]) BuyBuffer[i]  = fast[i];
      if(fast[i-1] >= slow[i-1] && fast[i] < slow[i]) SellBuffer[i] = fast[i];
   }
   return(rates_total);
}
Configurable parameters

Values you can adjust inside the indicator once you have it on your platform. The defaults already work.

FastPeriod (int, default 10)

Periodo de la media móvil rápida.

SlowPeriod (int, default 50)

Periodo de la media móvil lenta.

How to install it

Guarda el archivo como .mq5, ábrelo en MetaEditor y compílalo (F7). Después arrástralo al gráfico desde el Navegador de MetaTrader 5.

Warnings

Las flechas se pintan al cierre de la vela del cruce; no repintan velas pasadas.

Want to change anything?

Modifying what you generated with AI is a paid-plan feature. On the free plan you can generate, but not iterate on the result with AI.

Upgrade plan

Código educativo generado con IA. Revísalo y pruébalo en una cuenta demo antes de usarlo. Esto no es asesoramiento financiero.

Ready to use it with your data?

MQL5 and Pine Script indicator and strategy generator with AI · SuaVar