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
OnCalculateand writes its output to buffers. - Pine Script (TradingView): simpler and faster for testing an idea. It starts with
indicator()and draws withplotandplotshape.
Many people test the idea on TradingView first and build the MetaTrader version afterwards.
The build, step by step
- Write the rule on paper and mark it by hand on a chart.
- Keep inputs few: only what really needs to change.
- Code the calculation and draw the output (line, zone or arrow).
- Record signals only after the candle has closed.
- Add alerts:
AlertandSendNotificationin MQL5,alertconditionin Pine. - 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.