Coming from NinjaScript

A real import, the ideas side by side, and the names that translate.

This is a real run of the importer on a small NinjaScript script. The result compiles. 26 lines were read: 5 carried over exactly, 1 were adapted and 4 came back as decisions for you.

What you paste · NinjaScript
namespace NinjaTrader.NinjaScript.Strategies
{
public class MacdMomentum : Strategy
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Name = "MACD Momentum";
}
}
protected override void OnBarUpdate()
{
if (CrossAbove(EMA(Close, 12), EMA(Close, 26), 1))
{
SetStopLoss(CalculationMode.Ticks, 40);
SetProfitTarget(CalculationMode.Ticks, 80);
EnterLong();
}
if (CrossBelow(EMA(Close, 12), EMA(Close, 26), 1))
{
ExitLong();
}
}
}
}
What you get back
1strategy "MACD Momentum"
2market: EURUSD
3bars: 1h
4
5input risk = 1%
6
7when crosses_above(ema(close, 12), ema(close, 26)):
8buy risk: risk, stop: 40 points, target: 80 points
9
10when crosses_below(ema(close, 12), ema(close, 26)):
11close_all side: long

Line by line

StatusYour lineWhat happened
ExactSetStopLoss ( CalculationMode.Ticks , 40 ) ;a stop in ticks became points
Your call; SetProfitTarget ( CalculationMode.Ticks , 80 )this line has no equivalent yet
ExactSetProfitTarget ( CalculationMode.Ticks , 80 ) ;a stop in ticks became points
Your call; EnterLong ( ) ; }this line has no equivalent yet
AdaptedEnterLong ( ) ; } ifNinjaTrader sizes an order by the strategy settings, so this one risks a set share of the balance
Your call; } if ( CrossBelow (this line has no equivalent yet
Exactif ( CrossAbove ( EMA ( Close ,a condition became a rule
ExactExitLong ( ) ; } }an exit carried over
Your call; } } }this line has no equivalent yet
Exactif ( CrossBelow ( EMA ( Close ,a condition became a rule

How the ideas translate

In NinjaScriptIn AlgoBarsX
OnBarUpdate()the body of the script
EMA(Close, 12)ema(close, 12)
CrossAbove(a, b, 1)crosses_above(a, b)
SetStopLoss(CalculationMode.Ticks, 40)stop: 40 points, on the order itself
SetProfitTarget(CalculationMode.Ticks, 80)target: 80 points
EnterLong()buy
ExitLong()close_all side: long
Instrument, TickSizemarket.symbol, market.point_size
Tip. Set a stop with SetStopLoss before the entry. The import sizes the trade by risk, and a risk-based order needs a stop to measure from. The C# around the strategy (namespaces, State handling) comes back as notes, not code.

Names the importer translates for you

Their nameAlgoBarsX
currentbarbar.index
instrumentmarket.symbol
ticksizemarket.point_size
nullna
Read every import before you run it. Compare the plain-English description with what your original did, settle each decision, and backtest before you deploy.

Try this in the Terminal. AlgoBars is free: $0 a month, no card needed.

Create my free account