If I add a second bar with granularity ie 1 min some trades shows entry Time Date after the Exit Date!!
IE backtesting on ES#### on a 90 min series , RTH exit con close true I get that strange behavior.
Are the backtests not valid at all with increased granuality?
On others strategies is even more freqent!
#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 descrislion of your strategy here
/// </summary>
[Description("Enter the descrislion of your strategy here")]
public class A : Strategy
{
#region Variables
// Wizard generated variables
private int t=1;
// 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(PeriodType.Minute ,1);
this.ExitOnClose=true;
this.BarsRequired=1;
this.Slippage=1;
this.SetProfitTarget(CalculationMode.Ticks,3);
}
protected override void OnBarUpdate()
{
if(this.BarsInProgress==0)
{
bool buy;
if(SMA(Closes[0],50)[0]>SMA(Closes[0],200)[0])
buy=true;
else
buy=false;
if(buy&&MarketPosition.Flat==Position.MarketPositi on)
{
this.EnterLongLimit(1,true,1,Closes[0][0]-0.25*t,"BuyA");
return;
}
else if(!buy&&MarketPosition.Flat==Position.MarketPosit ion)
{
//
this.EnterShortLimit(1,true,1,Closes[0][0]+0.25*t,"SellA");
return;
}
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int T
{
get { return t; }
set {t= Math.Max(0,value); }
}
#endregion
}
}
Comment