TradingView · Pine Script

Pine Script developer for TradingView strategies and alerts

KMG Capital writes and repairs Pine Script for traders and trading firms: strategies you can backtest, indicators whose alerts follow the same trades, and bridges that send those alerts to a broker platform.

Work is led directly by founder Jad Kabbaj. Typical requests: turn an indicator into a strategy, make alerts match the backtest, add risk controls, or move a TradingView strategy to cTrader, MetaTrader 5, or NinjaTrader.

Pine Script work

From a chart idea to rules you can test and automate.

Every build keeps the source signal logic as the authority. Risk, time, and alert layers are added around it as settings, not rewritten into it.

01

Strategies you can backtest

strategy() scripts with fixed or percent-of-equity sizing, pip-based stop loss, take profit and trailing stop, session filters, end-of-day closes, and daily profit limits.

02

Indicators that follow the strategy

An indicator() that tracks the same position as the strategy (long, short or flat, entry, stop and target) so TradingView alerts fire on the same trades.

03

Alerts and automation

Alert sets for entries, exits, stop or target hits, end-of-day closes, and daily-limit locks, with webhook bridges that pass the signals to cTrader or MetaTrader 5.

From our conversion rules

Why TradingView alerts don’t match the strategy backtest.

A strategy() and an indicator() do not run the same way. The strategy keeps a position: when it is already long, a second buy signal does nothing. A plain indicator only sees signals, so it alerts on every one.

Example: the strategy is long and a new buy signal prints. The backtest ignores it. The indicator sends a second buy alert, and an automated account doubles the position.

The fix is an indicator that keeps the same position state as the strategy. It has to copy:

  • The same inputs, defaults, and confirmed-bar signals. A signal on the still-forming bar can appear and disappear before the close; the backtest only sees the final bar.
  • One position at a time, reversing on the opposite signal.
  • Stop, target, and trailing-stop exits, checked on every bar.
  • Session filters, end-of-day closes, and the once-a-day market-open entry.
  • The daily limit: no new entries once it is reached, and the open trade closed.

One case has no perfect answer: a bar that touches both the stop and the target. Bar data cannot show which came first. Our indicators take the stop:

// One bar touched both levels: OHLC data can't show which came first.
// Take the stop, so the alerts never look better than the strategy.
slHit = isLong ? low <= stopLevel : high >= stopLevel
tpHit = isLong ? high >= targetLevel : low <= targetLevel
if slHit or tpHit
    exitPrice = slHit ? stopLevel : targetLevel
    currentPosition := 0

TradingView’s strategy engine instead infers the order from where the bar opened, so on those rare bars the two can still differ. Taking the stop keeps any difference on the cautious side.

How it works

Rules first, then the code, then the alerts.

  1. 01

    Share the script or the rules

    Send the existing Pine Script, or describe the entry and exit rules, the market, the timeframe, and where the trades should run.

  2. 02

    Build and compare

    The strategy and its matching indicator are built with the same inputs and defaults, then compared on the chart so entries fire on the same bars.

  3. 03

    Hand over and automate

    You receive the source, the list of alerts, and setup notes. If needed, the alerts are connected to cTrader or MetaTrader 5 through a webhook bridge.

Common questions

Before you start

Can you turn my indicator into a strategy I can backtest?

Yes, when the signal rules are clear. The strategy keeps the indicator’s signal formula and inputs. Sizing, stop loss, take profit, and time filters are added as settings that start disabled, so the original behavior stays the default.

Can you work with a public script such as UT Bot or Hull Suite?

Yes. Open-source TradingView scripts keep their original author credit and license notice. The work adds the strategy, risk, and alert layers around them.

Can TradingView alerts place trades automatically?

For cTrader or MetaTrader 5, a webhook bridge receives each alert and places the order on the broker platform. The other option is to rebuild the strategy as a native cTrader cBot so it runs without TradingView.

Will the strategy be profitable?

A Pine Script build makes rules testable; it does not make them profitable. For an independent read on an existing strategy’s evidence and risks, see the Trading System Diagnostic. Nothing here is investment advice.

Pine Script development

Bring the script and what it should do.

Share the script or the rules, the market, and where the trades should run. Jad will reply directly with a useful next step.

KMG Capital provides research, software, and technical consulting. Nothing on this site constitutes investment advice or a guarantee of trading performance.