Deployment7 min read·Updated 11/19/2026

Exporting to MQL5, Pine Script and Python: What Differs Between Targets

Why the same block diagram produces different code for each platform, what a bar-shift convention is, why exports can be refused rather than silently translated, and what each destination can and cannot do.

Educational content only. It is not financial advice, and examples do not promise results.

A strategy is a diagram of conditions and actions. A platform is an environment with its own order model, its own notion of a bar, and its own way of handling time. Exporting is the act of translating one into the other, and translation is where assumptions surface. This guide explains what actually differs between the targets, why a faithful translation is not always possible, and what to check before you rely on exported code.

Key takeaways

  • The diagram is the source of truth. The exported code is a translation of it into a specific platform's model.
  • Bar shift conventions decide which bar a comparison reads; a one-bar difference changes the strategy.
  • Some platforms execute orders, others evaluate conditions and emit alerts, and one is used for research rather than execution.
  • Export is all-or-nothing: if a block cannot be expressed faithfully, the export is refused with a reason.
  • Re-test on the destination platform; results do not transfer by assumption.

Which targets exist, and what is each one for?

Lupuso exports to six destinations: MetaTrader 4 in MQL4, MetaTrader 5 in MQL5, TradingView in Pine Script, Python, cTrader in C#, and NinjaTrader in C#.

They are not interchangeable, and they are not all attempting the same job:

  • MQL4 and MQL5 run as an expert advisor inside the platform, with access to its order routing. These are execution targets.
  • Pine Script runs on TradingView's bar-by-bar evaluation model. Its natural output on that platform is an indicator and alert condition rather than an order placed by the script itself.
  • Python has no execution environment of its own. It is a research and data target: you get logic you can run against a data series, which is useful for study and for building your own execution layer.
  • C# for cTrader and NinjaTrader are execution targets with their own order APIs and their own backtesting engines.

Understanding which category a target falls into prevents the most common disappointment: expecting an evaluation-only script to place trades, or expecting a research script to behave like a live advisor without an execution layer added.

What is a bar-shift convention, and why does it matter?

Almost every rule in a diagram reads a bar's values. The question that decides what the rule means is which bar.

close[1] means the close of the last bar that has already finished. close[0] means the bar currently forming, whose close is not final and will keep changing until the bar ends. A rule written on the forming bar evaluates repeatedly during that bar, and each evaluation can give a different answer.

This is the single most consequential convention in an export, and it is easy to get wrong in either direction:

  1. Evaluating on the forming bar means the strategy can react within the bar, but the values it compares are provisional. A backtest that assumes those provisional values were known is showing you something that could not have been known.
  2. Evaluating on the closed bar means the values are final, but the action happens after the bar ends, which introduces a delay that must be accounted for.

Neither is wrong. They are different strategies. What matters is that the shift is stated explicitly, is the same in the diagram and in the exported code, and is applied consistently to every block that reads price or indicators. In Lupuso the shift is part of the block definition rather than a global hidden setting, which is what makes it checkable.

Why can an export be refused?

Export is all-or-nothing by design. If a block in the diagram cannot be represented faithfully on the chosen target, the export is refused and a reason is given, rather than producing code that behaves differently from what you drew.

This is not a limitation being hidden; it is the limitation being stated. Three situations commonly trigger it:

  • The target has no equivalent. A platform may not expose a function the block relies on, or may not expose it with the same semantics.
  • The order model differs. A block that assumes several independent positions on one symbol does not mean the same thing on a netting account, and a faithful translation may simply not exist.
  • Execution semantics cannot be reproduced. Timing, partial fills and requote behaviour belong to the destination platform, and a translation cannot promise them.

The useful response to a refusal is to read the reason, then decide whether to change the diagram, change the target, or accept that this particular combination is not available. Treating the refusal as information is considerably safer than receiving code that compiles and behaves subtly differently.

What does validation check before export?

Validation runs on the diagram itself, before any code is produced. It is about structure rather than about markets.

It looks for the things that make a diagram meaningless or self-contradictory: chains that do not connect from data to action, blocks whose inputs are missing, thresholds that were never set, and combinations whose meaning is ambiguous. Because every threshold in the variables and constants window becomes an input in the exported code, validation also covers whether those inputs are coherent together.

Validation cannot tell you whether a strategy is any good. It tells you whether the diagram describes something unambiguous enough to be translated. Those are different questions, and conflating them is how a diagram that compiles cleanly ends up not being the strategy you thought you had.

What should you check after exporting?

The export is the beginning of the work, not the end. Worth checking on the destination platform:

  1. Compile or load cleanly, and confirm the inputs that appear match the variables you defined.
  2. Bar shift, on one chart, by reading a logged condition against the bars you can see.
  3. Session and time handling, since the destination may stamp bars with a different server clock.
  4. Cost assumptions, then run the destination platform's own tester rather than assuming the diagram's results carry over.
  5. Order behaviour on a demo account, including what happens on a gap or when a request is rejected.

Step 4 deserves emphasis. A diagram's built-in simulator and a destination platform's tester use different data, different tick modelling and different cost handling. Both can be useful; they are not the same report, and treating them as interchangeable is a common source of confusion.

Common mistakes

  • Assuming an evaluation-only target will place orders, or that a research target will run unattended.
  • Mixing bar shifts, so that one block reads the forming bar and another reads the last closed bar.
  • Treating a refused export as a bug rather than as a statement about the diagram.
  • Reading the platform's tester output as if it were the same report the diagram produced.
  • Not re-checking time zone and session handling after moving to a different broker or platform.
  • Editing the exported code directly, so the code and the diagram diverge and the diagram is no longer the source of truth.

Risk note

Exported code is a translation, and translations can differ from the original in ways that only appear under live conditions. An export that validates cleanly describes an unambiguous diagram; it does not describe future market behaviour, and a clean backtest on either the built-in simulator or the destination platform is not a prediction. Trading carries a real risk of loss, and execution-related differences — spread, slippage, gaps, rejections and account type — can change what a rule actually does. Re-test on the destination platform, verify behaviour on a demo account before live use, keep position sizes small while you confirm that the code matches the diagram, and keep your risk limits inside the strategy so they survive any change of target.

English · Español · Français · Deutsch · Português · 中文 · العربية · हिन्दी · 9 supported locales