Code is below:
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class MyCustomStrategy : Strategy
{
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
// Add a 10 Range Bars object to the strategy - Primary Bar 1
Add(PeriodType.Range, 10);
Add("TF 12-10", PeriodType.Range, 15);
// Note: Bars are added to the BarsArray and can be accessed via an index value
// E.G. BarsArray[1] ---> Accesses the 5 minute Bars object added above
// Add simple moving averages to the chart for display
// This only displays the SMA's for the primary Bars object on the chart
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
{
// Checks for a cross above condition of the 8 and 18 period SMA on the primary Bars object and enters long
if (MACD(BarsArray[2](9, 12, 3)[0]) >= MACD(BarsArray[2](9,12,3).Avg)[0])
DrawArrowDown("My down arrow" + CurrentBar, false, 0, Low[0] + 15 * TickSize, Color.Yellow);
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = Math.Max(1, value); }
}
#endregion
}
}
Comment