#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>
/// Using an outside to inside crossover to entry market
/// </summary>
[Description("Using an outside to inside crossover to entry market")]
public class StochasticEntry : Strategy
{
#region Variables
// Wizard generated variables
private int low = 4; // Default setting for Low
private int high = 96; // Default setting for High
// 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()
{
SetProfitTarget("", CalculationMode.Ticks, 32);
SetStopLoss("", CalculationMode.Ticks, 8, false);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(Stochastics(7, 14, 3).D, 4, 1))
{
DrawArrowUp("My up arrow" + CurrentBar, false, 0, 0, Color.Cyan);
}
// Condition set 2
if (CrossBelow(Stochastics(7, 14, 3).D, 96, 1))
{
DrawArrowDown("My down arrow" + CurrentBar, false, 0, 0, Color.Magenta);
}
}
#region Properties
[Description("Low line in Stochastic")]
[GridCategory("Parameters")]
public int Low
{
get { return low; }
set { low = Math.Max(1, value); }
}
[Description("High line in Stochastic")]
[GridCategory("Parameters")]
public int High
{
get { return high; }
set { high = Math.Max(1, value); }
}
#endregion
}
}
Comment