GHADIMI FINANCEGHADIMI FINANCE

How to build a trading indicator for MT5 and TradingView

A good indicator starts with a clear rule, not with code. This guide follows the path from idea to code, alerts and testing.

By · GHADIMI FINANCE · about a 6-minute read

Before the code: write the rule

Every indicator answers three questions: what it shows on the chart, when it shows it and which data it uses. If you can’t write the rule in a few unambiguous sentences, neither a developer nor an AI can build it correctly. “An important high” is not a rule; “the highest high of the last 20 candles” is.

MQL5 or Pine Script?

  • MQL5 (MetaTrader 5): for traders who execute in MetaTrader and may later turn the same logic into an EA. The indicator is calculated in OnCalculate and writes its output to buffers.
  • Pine Script (TradingView): simpler and faster for testing an idea. It starts with indicator() and draws with plot and plotshape.

Many people test the idea on TradingView first and build the MetaTrader version afterwards.

The build, step by step

  1. Write the rule on paper and mark it by hand on a chart.
  2. Keep inputs few: only what really needs to change.
  3. Code the calculation and draw the output (line, zone or arrow).
  4. Record signals only after the candle has closed.
  5. Add alerts: Alert and SendNotification in MQL5, alertcondition in Pine.
  6. Compare against your hand-marked charts on several symbols and timeframes.

Repainting: the most important indicator bug

An indicator whose past signals later change or vanish looks perfect in history and is useless live. Three common causes: using the open candle, looking at future candles in the calculation, and reading higher-timeframe data before that candle has closed. To test it, run the indicator on a live chart, screenshot the signals and compare a few hours later. More in choosing and testing a signal indicator.

Building an indicator with AI

AI assistants can draft MQL5 and Pine Script code and find compile errors, provided they get a precise rule. State the language version, give the rule step by step and ask for closed-candle signals only. Read and test the code yourself; AI writes repainting indicators too unless you prevent it. More in AI in trading.

Common mistakes

  • Dozens of inputs nobody knows how to set.
  • Tuning inputs until the past looks beautiful (overfitting).
  • Recalculating the whole history on every tick and slowing the chart down.
  • No alerts, so the chart has to be watched all day.
  • Forgetting that an indicator only shows; size and stop loss are yours (lot size calculator).

GHADIMI FINANCE indicators

Mojtaba Ghadimi builds the GHADIMI FINANCE indicators on these principles: closed-candle signals, alerts and a live status on the chart. The EQ setup indicator for MetaTrader 5 and the G Candle indicator for MetaTrader 5 and TradingView. The setup logic is not published; it is taught in private training.

Want a ready-made indicator? See the GHADIMI FINANCE EQ setup and G Candle indicators; installation takes a few minutes.

See the indicators

FAQ

Which language do I need for a MetaTrader 5 indicator?

MQL5. The indicator is written and compiled in MetaEditor, and its calculation runs in the OnCalculate function.

Is it hard to build an indicator on TradingView?

No. Pine Script is designed for it and a simple indicator takes a few lines; the hard part is writing a precise rule.

What does repainting mean?

It means the indicator’s past signals later change or disappear. Such an indicator looks good in history but can’t be relied on live.

Related tools and articles

GHADIMI FINANCE products