This indicator basically allows you to define the pit open and pit close, so that it plots the OHLC figures from the pit traded session only, ignoring the Globex.
The problems -
1) The first issue is annoying, but can be worked around - However, I believe there must be a way of defining the correct start/end time. At the moment if you put in 09:00 as the start time on a 1min chart, it will actually plot the OPEN line at 08:59 because of the way the Ninja Time Stamping works - So, to get it to plot the Open at the correct time of 09:00est you need to input a start time of 09:01
This is not ideal and is an annoyance. Other indicators I have seem to allow for the Ninja TimeStamping, and I have never had to offset the time before.
Anyone point me how to resolve this in the code?
I admit, this is just an annoyance and it´s not really a big deal to just add the "chart time interval" to the values of open and close. Would be nice to fix it though :-)
Number 2 is a problem which I can´t find a workaround for.
2) The indicator does not plot correctly if you have an instrument which starts off on a non round number pit session start time - GC for instance starts at 08:20am EST.... Going by the above (1) theory I currently should have to put the start time as 08:21am, I do this but it still doesn´t plot the start time correctly, unless the chart has a time interval which is divisible by the number of minutes, for anything other than 1m this is hard to do.
For example, if I input 08:21 then it only plots correctly if I chose a 1minute or a 21minute time interval. If I input 08:20 as the start time, then it only plots correctly if I use a 1min, 2min, 5min, 10min chart interval. If I input 08:15 as the start time then it only plots the line if I use a 1, 3 or 5minute chart.
Pretty sure there are likely easy fixes for both of these, but I am stumped.
Appreciate any help. I am hoping these indicators would be very useful to many who want to plot the OHLC of the Pit Session, yet plot all the Globex session on charts.
Below attached is the current code.
{
#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
private DateTime currentDate = Cbi.Globals.MinDate;
private double currentOpen = 0;
private double currentHigh = 0;
private double currentLow = 0;
private double currentClose = 0;
private double priordayOpen = 0;
private double priordayHigh = 0;
private double priordayLow = 0;
private double priordayClose = 0;
private bool showOpen = true;
private bool showHigh = true;
private bool showLow = true;
private bool showClose = true;
#endregion
int dayStart = 800;
int dayEnd = 2200;
int onDay = 0;
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.Orange, PlotStyle.Hash, "Prior Open"));
Add(new Plot(Color.Green, PlotStyle.Hash, "Prior High"));
Add(new Plot(Color.Red, PlotStyle.Hash, "Prior Low"));
Add(new Plot(Color.Firebrick, PlotStyle.Hash, "Prior Close"));
Plots[0].Pen.DashStyle = DashStyle.Dash;
Plots[3].Pen.DashStyle = DashStyle.Dash;
AutoScale = false;
Overlay = true; // Plots the indicator on top of price
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (Bars == null)
return;
if (!Bars.BarsType.IsIntraday)
{
DrawTextFixed("error msg", "PriorDayOHLC only works on intraday intervals", TextPosition.BottomRight);
return;
}
//if (onDay != Time[0].Day)
//{
// if (currentOpen != 0)
// {
// priordayOpen = currentOpen;
// priordayHigh = currentHigh;
// priordayLow = currentLow;
// priordayClose = currentClose;
// if (ShowOpen) PriorOpen.Set(priordayOpen);
// if (ShowHigh) PriorHigh.Set(priordayHigh);
// if (ShowLow) PriorLow.Set(priordayLow);
// if (ShowClose) PriorClose.Set(priordayClose);
// }
// onDay = Time[0].Day;
//}
//else
//{
//}
// If the current data is not the same date as the current bar then its a new session
if (currentDate != Bars.GetTradingDayFromLocal(Time[0]) || currentOpen == 0)
{
// The current day OHLC values are now the prior days value so set
// them to their respect indicator series for plotting
if (currentOpen != 0)
{
priordayOpen = currentOpen;
priordayHigh = currentHigh;
priordayLow = currentLow;
priordayClose = currentClose;
if (ShowOpen) PriorOpen.Set(priordayOpen);
if (ShowHigh) PriorHigh.Set(priordayHigh);
if (ShowLow) PriorLow.Set(priordayLow);
if (ShowClose) PriorClose.Set(priordayClose);
}
// Initilize the current day settings to the new days data
currentOpen = Open[0];
currentHigh = High[0];
currentLow = Low[0];
currentClose = Close[0];
currentDate = Bars.GetTradingDayFromLocal(Time[0]);
}
else // The current day is the same day
{
if (ToTime(Time[0]) == dayStart * 100) currentOpen = Open[0];
if (ToTime(Time[0]) > dayStart * 100 && ToTime(Time[0]) < dayEnd * 100)
{
// Set the current day OHLC values
currentHigh = Math.Max(currentHigh, High[0]);
currentLow = Math.Min(currentLow, Low[0]);
currentClose = Close[0];
}
if (ShowOpen) PriorOpen.Set(priordayOpen);
if (ShowHigh) PriorHigh.Set(priordayHigh);
if (ShowLow) PriorLow.Set(priordayLow);
if (ShowClose) PriorClose.Set(priordayClose);
}
}
#region Properties
[Description("")]
[Category("Parameters")]
public int DayStart
{
get { return dayStart; }
set { dayStart = Math.Max(0, value); }
}
[Description("")]
[Category("Parameters")]
public int DayStop
{
get { return dayEnd; }
set { dayEnd = Math.Max(1, value); }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries PriorOpen
{
get { return Values[0]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries PriorHigh
{
get { return Values[1]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries PriorLow
{
get { return Values[2]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries PriorClose
{
get { return Values[3]; }
}
[Browsable(true)]
[Gui.Design.DisplayNameAttribute("Show open")]
public bool ShowOpen
{
get { return showOpen; }
set { showOpen = value; }
}
[Browsable(true)]
[Gui.Design.DisplayNameAttribute("Show high")]
public bool ShowHigh
{
get { return showHigh; }
set { showHigh = value; }
}
[Browsable(true)]
[Gui.Design.DisplayNameAttribute("Show low")]
public bool ShowLow
{
get { return showLow; }
set { showLow = value; }
}
[Browsable(true)]
[Gui.Design.DisplayNameAttribute("Show close")]
public bool ShowClose
{
get { return showClose; }
set { showClose = value; }
}
#endregion
}
}

Comment