I would like to backtest a strategy using instruments based in Australia and the UK.
I have daily data for the Australian stock index and minute data for UK stock, and want to use the daily change, i.e. Closes[(0)][0] > Opens[(0)][0], in the Australian index to decide whether to buy a stock at the start of the UK session.
Unfortunately when I try this, the values of the Closes[(0)][0] and Opens[(0)][0] are for the PREVIOUS day. So if it is Tuesday morning in the UK, we should already have the value for the Tuesday Close and Open for the Australian index. However, the values that NinjaTrader uses are for the day before, i.e. Monday.
Could someone let me know what is the best way around this issue?
Thanks
ST10
#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>
/// </summary>
[Description("")]
public class DLv1vDATATEST1 : Strategy
{
#region Variables
// Wizard generated variables
#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("GSK", PeriodType.Minute, 1);
CalculateOnBarClose = true;
ExitOnClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (BarsInProgress == 1)
{
if (Bars.FirstBarOfSession)
{
if (Position.MarketPosition == MarketPosition.Flat)
{
Print(Time[0] + " : " + Closes[0][0] + " : " + Opens[0]);
if (Closes[(0)][0] > Opens[(0)][0])
{
EnterLong();
}
else if (Closes[(0)][0] < Opens[(0)][0])
{
EnterShort();
}
}
}
}
}
#region Properties
#endregion
}
}

Comment