Session Start: 01/01/0001 00:00:00 Session End: 01/01/0001 00:00:00143.513333333333
and then the output starts at 10/1/2013 not 6/12/12 (when the chart starts),
Session Start: 10/01/2013 08:00:00 Session End: 10/01/2013 22:00:00143.513333333333
Here is the code,
#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 description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class PivotTrader : Strategy
{
#region Variables
private double r2;
private double r1;
private double pp;
private double s1;
private double s2;
private DateTime sessionBegin;
private DateTime sessionEnd;
#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.Day, 1);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if(CurrentBars[1] <= 1)
return;
if(CurrentBars[1] == null)
return;
if (Bars.FirstBarOfSession)
Bars.Session.GetNextBeginEnd(BarsArray[1], 0, out sessionBegin, out sessionEnd);
// Calculate Pivot Points
pp = (Highs[1][1] + Lows[1][1] + Closes[1][1])/3;
//DrawLine("pp" + CurrentBars[1], false, sessionBegin, pp, sessionEnd, pp, Color.Red, DashStyle.Solid,1);
Print("Session Start: " + sessionBegin + " Session End: " + sessionEnd + pp);
}
}
}
Comment