I am trying to get my entries to happen on 5 minute Last bars and my exits to happen (and plot) on 1 tick Bid bars. The purpose of this is so I can see exactly which Bid tick caused my exit to happen.
I followed NT7's instructions on how to do multi time frame entries/exits (shown here http://ninjatrader.com/support/forum...ead.php?t=5787) the best I could
but for some reason I can only get the exits to happen (and plot) on the 5 minute last bars and not the 1 tick Bid bars.
The code I wrote to test this out is below (Its a simple MACD strategy). Any idea what I did wrong?
(FYI: You'll see I did not add anything within the code to plot the bars on the chart. Instead I just manually added a 5 min Last bar series and 1 tick Bid bar series to the chart before adding the strategy to the chart and running it in replay mode).
Also, a zip file of the code is attached in case anyone prefers importing it into NT7 to view.
Thanks!
#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
namespace NinjaTrader.Strategy
{
[Description("Enter the description of your strategy here")]
public class MACDCROSS : Strategy
{
#region Variables
#endregion
protected override void Initialize()
{
// Add a 5 minute Bars object to the strategy
Add("ES 03-16",PeriodType.Minute, 5, MarketDataType.Last);
// Add a 1 tick Bid bars to the strategy
Add("ES 03-16",PeriodType.Tick, 1, MarketDataType.Bid);
CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 0)
{
if (CrossBelow(MACD(12, 26, 9).Avg, MACD(12, 26, 9), 1))
{
EnterLong(1, "");
}
}
if (BarsInProgress == 1)
{
if (Position.GetProfitLoss(Close[0], PerformanceUnit.Points) >= 2)
{
ExitLong("", "");
}
if (Position.GetProfitLoss(Close[0], PerformanceUnit.Points) <= -2)
{
ExitLong("", "");
}
}
}
#region Properties
#endregion
}
}

Comment