Data Feed: IQFeed
Symbol: TF
BarType: 1440 Minute (to get the CME RTH session daily bar)
I created a strategy that adds a secondary series (5 minute bars) so
that I can enter 5 minutes before the close given calculations on the
primary series being the 1440 minute bars.
Is there a way to use the partial bar formed on the 1440 minute series
5 minutes before the close of that bar for calculations?
Or is there another way around this?
The other idea I had is the ability to add a data series with a different session template applied. I was wondering if that could be supported in NT8?
Thanks in advance!
public class TestStrategy : Strategy
{
private int smaLength = 200;
protected override void Initialize()
{
Add(PeriodType.Minute, 5);
CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
if (CurrentBar < smaLength) return;
if (BarsInProgress == 0)
{
double sma = SMA(Close, smaLength)[0];
string msg = string.Format("BARS1 [Date] {0} [Time] {1} [sma] {2}",
Time[0].ToShortDateString(), Time[0].ToShortTimeString(), sma.ToString("N2"));
Print(msg);
}
else if (BarsInProgress == 1 && Time[0].Hour == 15 && Time[0].Minute == 10)
{
double sma = SMA(BarsArray[0], smaLength)[0];
// EXITS
if (sma < Close[0])
ExitLongLimit(1, false, 1, Close[0], "LX", "LE");
// ENTRIES
if (IsFlat && Close[0] > sma)
EnterLongLimit(1, false, 1, Close[0], "LE");
string msg = string.Format("BARS2 [Date] {0} [Time] {1} [sma] {2}",
Time[0].ToShortDateString(), Time[0].ToShortTimeString(), sma.ToString("N2"));
Print(msg);
}
else
{
return;
}
}
[Description("")]
[GridCategory("Parameters")]
public int SmaLength
{
get { return smaLength; }
set { smaLength = Math.Max(1, value); }
}
}

Comment