I am new in Ninja trading, I have a problem in drawing pivots. A kind of problem is my pivots starts at "12:00 PM" and ends at "12:00 PM" which range type is daily, what I want is to start my pivots line at "6:00 AM" and ends at "5:17 PM" session template. Do you have any Idea which part of the code to be change? Please help. Here is the code:
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
{
if (Bars == null || ChartControl == null)
return;
int barWidth = ChartControl.ChartStyle.GetBarPaintWidth(ChartCont rol.BarWidth);
for (int seriesCount = 0; seriesCount < Values.Length; seriesCount++)
{
SolidBrush brush = brushes[seriesCount];
DateTime lastDate = Cbi.Globals.MinDate;
DateTime lastWeek = Cbi.Globals.MinDate;
DateTime lastMonth = Cbi.Globals.MinDate;
int firstX = -1;
int lastX = -1;
int lastY = -1;
int xcounter = 0;
SmoothingMode oldSmoothingMode = graphics.SmoothingMode;
GraphicsPath path = new GraphicsPath();
DataSeries series = (DataSeries)Values[seriesCount];
Gui.Chart.Plot plot = Plots[seriesCount];
if (brush.Color != plot.Pen.Color && Textcolorispencolor)
brush = new SolidBrush(plot.Pen.Color);
else
brush = new SolidBrush(TextColor);
for (int count = ChartControl.BarsPainted - 1; count >= ChartControl.BarsPainted - (Math.Min(ChartControl.BarsPainted, Width)+500); count--)
{
int idx = ChartControl.LastBarPainted - ChartControl.BarsPainted + 1 + count;
if (idx - Displacement < 0 || idx - Displacement >= Bars.Count || (!ChartControl.ShowBarsRequired && idx - Displacement < BarsRequired))
continue;
else if (!series.IsValidPlot(idx))
continue;
if (pivotRangeType == PivotRange.Daily && lastDate == Cbi.Globals.MinDate && sessionTemplate == false)
lastDate = Bars.Get(idx).Time.Date;
else if (pivotRangeType == PivotRange.Weekly && lastWeek == Cbi.Globals.MinDate && sessionTemplate == false)
lastWeek = RoundUpTimeToPeriodTime(Bars.Get(idx).Time.Date, PivotRange.Weekly);
else if (pivotRangeType == PivotRange.Monthly && lastMonth == Cbi.Globals.MinDate && sessionTemplate == false)
lastMonth = RoundUpTimeToPeriodTime(Bars.Get(idx).Time.Date, PivotRange.Monthly);
else if (pivotRangeType == PivotRange.Daily && lastDate != Bars.Get(idx).Time.Date
|| pivotRangeType == PivotRange.Weekly && lastWeek != RoundUpTimeToPeriodTime(Bars.Get(idx).Time.Date, PivotRange.Weekly)
|| pivotRangeType == PivotRange.Monthly && lastMonth != RoundUpTimeToPeriodTime(Bars.Get(idx).Time.Date, PivotRange.Monthly) && sessionTemplate == false)
continue;
double val = series.Get(idx);
int x = (int)(ChartControl.CanvasRight - ChartControl.BarMarginRight - barWidth / 2
- (ChartControl.BarsPainted - 1) * ChartControl.BarSpace + count * ChartControl.BarSpace);
int y = (int)((bounds.Y + bounds.Height) - ((val - min) / Gui.Chart.ChartControl.MaxMinusMin(max, min)) * bounds.Height);
if (xcounter == 0)
{
firstX = x;
}
if (lastX >= 0)
{
if (y != lastY) // Problem here is, that last bar of old day has date of new day
y = lastY;
path.AddLine(lastX - plot.Pen.Width / 2, lastY, x - plot.Pen.Width / 2, y);
}
lastX = x + RtMargin;
lastY = y;
xcounter++;
}
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.DrawPath(plot.Pen, path);
graphics.SmoothingMode = oldSmoothingMode;
}
}
#endregion
Comment