When compiling, I see the initials Print, but none of the OnBarUpdate ones (make sense), but when running the backtesting the output window stays clean I run the test over the last month only).
Here is the code. Any help is blessed.
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>
/// BDTtheTradeScalper
/// </summary>
[Description("BDTtheTradeScalper")]
public class BDTtheTradeScalper : Strategy
{
#region Variables
// Wizard generated variables
private int activeMin = 12; // Default setting for ActiveMin
private string aTRprofitTicks = @"000002030303040404"; // Default setting for ATRprofitTicks
private string aTRstopTicks = @"000005060607080809"; // Default setting for ATRstopTicks
private string newsHours = @"0830100014001430"; // Default setting for NewsHours
private int newsBrake = 2; // Default setting for NewsBrake
private double minATR = 2.000; // Default setting for MinATR
private double profitTicks = 3; // Default setting for ProfitTicks
private double stopTicks = 6; // Default setting for StopTicks
// User defined variables (add any user defined variables below)
int LongCount = 0;
int ShortCount = 0;
#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, ProfitTicks);
SetStopLoss("", CalculationMode.Ticks, StopTicks, false);
CalculateOnBarClose = true;
//ClearOutputWindow();
TraceOrders = true;
Print("Run " + DateTime.Now.ToString("dd/MM/yyyy") + "," + DateTime.Now.ToString("HH:mm:ss") + " | " +aTRprofitTicks);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
Print(Time[0].ToString("dd/MM/yyyy") + "," + Time[0].ToString("HH:mm:ss") + "," + Open[0] + "," + High[0] + "," + Low[0] + "," + Close[0]);
// Condition set 1
if (BDTttsCurBarNum()[0] == 15)
{
LongCount = 0;
ShortCount = 0;
ExitLong("", "ScpLnog");
ExitShort("", "ScpShort");
}
Print("---CurBarNum: " + BDTttsCurBarNum()[0]);
Print(" LongCount: " + LongCount);
Print(" ShortCount: " + ShortCount);
// Condition to Scalp
if (BDTttsCurBarNum()[0] <= ActiveMin
&& ATR(4)[0] >= MinATR * TickSize)
{
Print(" Condition Right");
// First Condition Long per period
if (LongCount == 0)
{
// R#1 - Crose above previous high
if (CrossAbove(Close, BDTttsPerivousHigh(), 1))
{
Print(" R#1 Enter Long: " + BDTttsPerivousHigh());
EnterLongLimit(0, true, DefaultQuantity, BDTttsPerivousHigh()[0], "ScpLong");
LongCount++;
}
// R#2 - 2 Consecutive wicks higher over previous high
if (Close[0] == Open[0]
&& High[0] > BDTttsPerivousHigh()[0]
&& Close[1] == Open[1]
&& High[1] > BDTttsPerivousHigh()[1])
{
Print(" R#2 Enter Long: " + Close[0]);
EnterLongLimit(0, true, DefaultQuantity, Close[0], "ScpLong");
LongCount++;
}
}
// First Condition Short per period
if (ShortCount == 0)
{
// R#1 - Crose below previous low
if (CrossBelow(Close, BDTttsPerivousLow(), 1))
{
Print(" R#1 Enter Short: " + BDTttsPerivousLow()[0]);
EnterShortLimit(0, true, DefaultQuantity, BDTttsPerivousLow()[0], "ScpShort");
ShortCount++;
}
// R#2 - 2 Consecutive wicks higher over previous high
if (Close[0] == Open[0]
&& Low[0] < BDTttsPerivousLow()[0]
&& Close[1] == Open[1]
&& Low[1] < BDTttsPerivousLow()[1])
{
Print(" R#2 Enter Short: " + Close[0]);
EnterShortLimit(0, true, DefaultQuantity, Close[0], "ScpShort");
ShortCount++;
}
}
}
}
#region Properties
[Description("String with Limit order Enter rules")]
[GridCategory("Parameters")]
public int ActiveMin
{
get { return activeMin; }
set { activeMin = Math.Max(1, value); }
}
[Description("String with 2 digits Exit Profit rules")]
[GridCategory("Parameters")]
public string ATRprofitTicks
{
get { return aTRprofitTicks; }
set { aTRprofitTicks = value; }
}
[Description("String with 2 digits Exit Limit rules")]
[GridCategory("Parameters")]
public string ATRstopTicks
{
get { return aTRstopTicks; }
set { aTRstopTicks = value; }
}
[Description("String with 4 digits hours")]
[GridCategory("Parameters")]
public string NewsHours
{
get { return newsHours; }
set { newsHours = value; }
}
[Description("Length of News Brake")]
[GridCategory("Parameters")]
public int NewsBrake
{
get { return newsBrake; }
set { newsBrake = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public double MinATR
{
get { return minATR; }
set { minATR = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public double ProfitTicks
{
get { return profitTicks; }
; }
set { profitTicks = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public double StopTicks
{
get { return stopTicks; }
set { stopTicks = Math.Max(1, value); }
}
#endregion
}
}

Comment