Entry is based on Unirenko Projected Bar Closes v2
Chart is 1 14 2 Unirenko
Buy 1 Contract when the unirenko changes from Red to Blue (closes) and places a pending Stop order 1 tick above the high of the Projected Bar Closes indicator (dashed yellow line).
I got it to work but once I exit the trade it continues placing buy orders on every new bar.
Here is the code. Also, I tried making another strategy to sell (not sure if I can combine both buy and sell in the same strategy?) But that one doesn't place any orders.
Any help would be much appreciated.
#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
{
///
/// Unirenko bar closes ordering
///
[Description("Unirenko bar closes ordering")]
public class BarCloses : Strategy
{
#region Variables
// Wizard generated variables
private int up = 1; // Default setting for Up
// User defined variables (add any user defined variables below)
#endregion
///
/// This method is used to configure the strategy and is called once before any strategy method is called.
///
protected override void Initialize()
{
Add(UniRenkoBarCloses());
SetProfitTarget("", CalculationMode.Ticks, 15);
SetStopLoss("", CalculationMode.Ticks, 16, false);
CalculateOnBarClose = true;
}
///
/// Called on each bar update event (incoming tick)
///
protected override void OnBarUpdate()
{
// Condition set 1
if (UniRenkoBarCloses()[0] + 1 * TickSize > Close[1])
{
EnterLongStop(DefaultQuantity, Close[0] + 1 * TickSize, "BuyDarren");
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int Up
{
get { return up; }
set { up = Math.Max(1, value); }
}
#endregion
}
}
#region Wizard settings, neither change nor remove
/*@