Complete Suite: all 12 tools. 6 Premium desks inside.All 12 tools $606.98 one by one

$606.98 one by one $97 once Save $509.98Get the SuiteGet it

cTrader to Pine Script converter

Paste a cTrader Automate C# (.cs) indicator or cBot and read the Pine Script v6 beside it, line for line.

Updated 11 November 2026. Runs in your browser; nothing you type is uploaded.

Sample cTrader Automate C# indicatorPine Script v6, ready to paste

cTrader [Parameter] & [Output] attributes, Initialize() EMA + Wilder ATR handles, and Calculate(int index) series assignments.

Pine Script v6 draft (13/13 mapped · indicator())

Runs strictly in your browser tab — no C# or .algo files are uploaded. Verify bar-close behavior in Pine Script repaint & v6 checker before trading live.

Share this calculator

Post on XPost to Reddit
Embed or cite it on your site

Free on any site, blog, Notion page or Substack: paste this code to show the live calculator. The credit line is optional; keep it, edit it, add rel="nofollow" or remove it.

<iframe src="https://proea.app/embed/tools/ctrader-to-pine-script-converter" title="cTrader to Pine Script converter" loading="lazy" referrerpolicy="strict-origin-when-cross-origin" style="display:block;width:100%;height:820px;border:0;border-radius:12px"></iframe>
<p style="font-size:12px">cTrader to Pine Script converter by <a href="https://proea.app/en/tools/ctrader-to-pine-script-converter?utm_source=embed&utm_medium=referral&utm_campaign=ctrader-to-pine-script-converter">ProEA</a></p>

Writing about it instead? Cite the method and link the page:

The math: Indicators.ExponentialMovingAverage(Bars.ClosePrices, 21) = ta.ema(close, 21) · [Output] = plot()

How cTrader Initialize() handles + Calculate(int index) become Pine Script v6

In cTrader Automate (cAlgo.API), indicators instantiate built-in series once inside Initialize() (or OnStart() in a cBot) and index bar index chronologically from 0 up to the current bar. Every row below is generated at build time by pineForCtrader().

cTrader Automate C# (cAlgo.API)Pine Script v6
_ema = Indicators.ExponentialMovingAverage(Bars.ClosePrices, 21);float h_ema = ta.ema(close, 21)
_sma = Indicators.SimpleMovingAverage(Bars.MedianPrices, 50);float h_sma = ta.sma(hl2, 50)
_rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 14);float h_rsi = ta.rsi(close, 14)
_atr = Indicators.AverageTrueRange(14, MovingAverageType.WilderSmoothing);float h_atr = ta.atr(14)
_bb = Indicators.BollingerBands(Bars.ClosePrices, 20, 2.0, MovingAverageType.Simple);[h_bb_mid, h_bb_top, h_bb_bot] = ta.bb(close, 20, 2.0)
_macd = Indicators.MacdCrossOver(Bars.ClosePrices, 26, 12, 9);[h_macd_macd, h_macd_signal, h_macd_hist] = ta.macd(close, 12, 26, 9)
_stoch = Indicators.StochasticOscillator(14, 3, 3, MovingAverageType.Simple);float h_stoch_k = ta.sma(ta.stoch(close, high, low, 14), 3) float h_stoch_d = ta.sma(h_stoch_k, 3)
_dms = Indicators.DirectionalMovementSystem(14);[h_dms_diPlus, h_dms_diMinus, h_dms_adx] = ta.dmi(14, 14)
Bars.ClosePrices[index - 1];close[1]
Functions.HasCrossedAbove(_fast, _slow, 0);ta.crossover(_fast, _slow)
Why cTrader MacdCrossOver(26, 12, 9) and Bars.ClosePrices[index - 1] need care

Two silent traps trip manual ports between cTrader C# and TradingView Pine Script v6: first, Indicators.MacdCrossOver(source, longCycle, shortCycle, signalPeriods) takes the slow period before the fast period, whereas Pine's ta.macd(source, fastlen, slowlen, siglen) takes fast first—the converter swaps them automatically. Second, cTrader indexes oldest-to-newest ([index] is the current bar and [index - 1] or .Last(1) is one bar ago), which maps to Pine's close and close[1].

cTrader [Parameter], [Output] attributes and cBot orders

C# property attributes become TradingView settings and plot() calls; ExecuteMarketOrder() and ClosePosition() map to strategy.entry(), strategy.exit() and strategy.close_all().

cTrader Automate C# (cAlgo.API)Pine Script v6
[Parameter("Fast EMA", DefaultValue = 21, MinValue = 2)] public int FastLen { get; set; }FastLen = input.int(21, "Fast EMA", minval = 2)
[Output("Basis", LineColor = "DodgerBlue", PlotType = PlotType.Line, Thickness = 2)] public IndicatorDataSeries Basis { get; set; }plot(Basis, "Basis", color = color.blue, linewidth = 2)
ExecuteMarketOrder(TradeType.Buy, SymbolName, 10000, "TrendBot", 25, 50);strategy.entry("TrendBot", strategy.long) strategy.exit("Exit " + "TrendBot", "TrendBot", loss = 25 * 10, profit = 50 * 10)
ClosePosition(position);strategy.close_all()

Source-enabled .algo packages vs compiled .NET binaries

Drop a .cs, .algo or .zip file above—everything stays inside your browser.

When can a cTrader .algo file convert to Pine Script?
  • .algo built with "Include source code": cTrader packages the indicator or cBot as a ZIP archive containing the editable .cs file alongside the compiled assembly. Our browser unpacker extracts the .cs source locally without uploading your file.
  • Closed-source .algo or .dll binaries: When an author builds without source code, the .algo archive holds only compiled .NET IL binaries. Those cannot be read as source code and are never decompiled here.
  • Pending orders, Chart.Draw* objects & OnTick() execution: cBot methods like PlaceLimitOrder(), ModifyPosition() and Chart.DrawTrendLine() are marked TODO(cTrader) with their exact C# line numbers. If you also track cTrader exports, see our cTrader trading journal & statement guide.
  • Converting from another platform? Try our MQL5 (.mq5) to Pine v6 converter, MQL4 (.mq4) to Pine v6 converter, NinjaScript (NT8 C#) to Pine v6 converter, or thinkScript to Pine v6 converter.
Method and privacy

Method: Runs in your browser over src/lib/tools/ctrader-to-pine: maps [Indicator] and [Robot] classes, [Parameter] and [Output] attributes, Initialize() and OnStart() indicator handles (ExponentialMovingAverage, SimpleMovingAverage, WeightedMovingAverage, HullMovingAverage, WellesWilderSmoothing, MovingAverage, RelativeStrengthIndex, AverageTrueRange, StandardDeviation, CommodityChannelIndex, BollingerBands, MacdCrossOver with fast/slow cycle swap, StochasticOscillator, DirectionalMovementSystem and closed-bar MarketData.GetBars), unfolds Calculate(int index) and OnBar() series indexing (Bars.ClosePrices[index - k], .Last(k)), Functions.HasCrossedAbove/HasCrossedBelow and ExecuteMarketOrder/ClosePosition, and checks the draft with our static Pine v6 checker. Closed-source .algo/.dll binaries, pending limit/stop orders and Chart.Draw* objects are flagged TODO rather than guessed.

Calculations run entirely in your browser — nothing you type is uploaded. Your last numbers stay in this browser so you can pick up where you left off; Forget them clears them. A link with your numbers carries them after the # sign, which browsers do not send to servers, and the page takes them out of the address before any analytics loads. Copy and download actions save your calculation locally. The site may record coarse tool actions under its privacy policy, without inputs, results, file contents or filenames.

Common questions

Can you convert a cTrader .algo file to Pine Script?

Only when the .algo file was built with 'Include source code' enabled in cTrader Automate. Source-enabled .algo files are ZIP packages containing the plain-text .cs source, which our converter unpacks locally in your browser. Closed-source .algo files contain only compiled .NET binaries and cannot be decompiled.

How do cTrader Initialize() handles and Calculate(int index) map to Pine Script v6?

In cTrader Automate (cAlgo.API), an indicator creates handles inside Initialize()—such as _ema = Indicators.ExponentialMovingAverage(Bars.ClosePrices, 21)—and writes output values at [index] inside Calculate(int index). Pine Script v6 evaluates top-level series expressions across every bar automatically and plots each [Output] series with plot().

Why does Indicators.MacdCrossOver(source, 26, 12, 9) flip parameters in Pine Script?

cTrader's MacdCrossOver(source, longCycle, shortCycle, signalPeriods) passes the slow period (26) before the fast period (12), whereas TradingView's ta.macd(source, fastlen, slowlen, siglen) expects fast (12) before slow (26). The converter swaps those two arguments automatically so the histogram sign matches.

How do cBot OnBar() and ExecuteMarketOrder() convert to a Pine strategy?

A cBot's OnBar() callback runs once when a bar closes, matching Pine Script v6's default bar-close strategy() model. ExecuteMarketOrder(TradeType.Buy/Sell, ...) maps to strategy.entry() (plus an optional strategy.exit() when stop-loss or take-profit pips are supplied), and ClosePosition() maps to strategy.close_all().

Are my .cs or .algo files uploaded to any server?

No. Unpacking .algo/.zip archives and translating C# to Pine Script v6 happen strictly inside your browser tab; your source code is never uploaded, logged or stored.

Fix, build or get finished Pine v6

  • Pine Fixer An AI skill pack for 45 compiler-verified Pine v6 failure classes, with a repaint clinic. $9.99 once.
  • Pine Starter Stack Prompt Vault, Builder Lite and Pine Fixer in one zip. $19.99 once.
  • Pine Pro Library 19 TradingView desks with their full Pine v6 source and every update. $49 once.

Goes deeper

Limits and trading risk

These tools calculate from your inputs, supported historical records or explicitly labelled teaching examples. They do not verify a live account, predict future returns or confirm that a broker or prop-firm rule has been met. Missing costs, floating losses and changed market conditions can materially change outcomes. Trading can lose the capital committed to it; check the stated method and your account specifications.

Read the risk disclosure