NinjaTrader is a rapidly growing trading application that utilizes C# to program your own custom indicators and automated trading strategies. All code examples (or NinjaScript as the platform refers to them) on this website are programmed for the NinjaTrader platform. For a complete description of how to program for NinjaTrader, please see the official website here.
Below is a quick guide on how to get started with the indicator examples posted on this blog. The strategy wizard is very similar and will be detailed later if there is sufficient demand for it.
Part 1
Choose "Tools > New NinjaScript > Indicator..."
Click "Next" to get to the next window.
Do exactly what the wizard tells you: enter your indicator name and a brief description.
For ease of use with code from this blog, delete all the default values on the next few pages. Until you get to the last page...
Click "Generate" instead of finish to take you to the NinjaScript Editor window.
Part 2
You should be left with something like the following code, pay attention to the parts in bold:
// Using declarations
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
///
/// My Indicator Name
///
[Description("My Indicator")]
public class MyIndicator : Indicator
{
#region Variables
// Wizard generated variables
///
/// This method is used to configure the indicator and is called once before any bar data
/// is loaded.
///
protected override void Initialize()
{
CalculateOnBarClose = true;
Overlay = true; // Displays your indicator over the price bars or separately.
PriceTypeSupported = false;
}
}
///
/// Called on each bar update event (incoming tick)
///
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values.
#region Properties
#endregion
}
}
// NinjaScript generated code. Neither change nor remove.
// This namespace holds all indicators and is required. Do not change it.
That's it! Just edit the bold sections above and you should be good to go. Happy programming!