Code:
public class NinjaTerminalInternal : Strategy
{
public double DailyDifference;
private bool _InShort = false;
private bool _InLong = false;
private int _InQuantity = 0;
private bool Traded = false;
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = false;
Days2Load = 5;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
TraceOrders = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (Historical && !Traded)
{
if (InLong)
{
EnterLong(InQuantity);
Print("Entering Long");
}
if (InShort)
{
EnterShort(InQuantity);
}
Traded = !Traded;
}
double diff = (-(CurrentDayOHL().CurrentOpen[0] - Close[0]) / Close[0]) * 100;
DailyDifference = Math.Round(diff,2,MidpointRounding.AwayFromZero);
}
[GridCategory("Parameters")]
public int InQuantity
{
get { return _InQuantity; }
set { _InQuantity = Math.Max(0, value); }
}
[GridCategory("Parameters")]
public bool InShort
{
get { return _InShort; }
set { _InShort = value; }
}
[GridCategory("Parameters")]
public bool InLong
{
get { return _InLong; }
set { _InLong = value; }
}
}

Comment