private SolidBrush downBrush=new SolidBrush(Color.Red);

private SolidBrush upBrush= new SolidBrush(Color.Green);

public override void PaintBars(NinjaTrader.Gui.Chart.ChartControl chartControl, Graphics graphics, NinjaTrader.Data.Bars bars, int panelIdx, int fromIdx, int toIdx, Rectangle bounds, double max, double min)

{

if (bars.BarsType.DisplayName.Contains("STR"))

{

if (this.downBrush.Color != this.DownColor)

{

this.downBrush.Color = this.DownColor;

}

if (this.upBrush.Color != this.UpColor)

{

this.upBrush.Color = this.UpColor;

}

int barWidthUI = bars.BarsData.ChartStyle.BarWidthUI;

Color color2 = base.Pen.Color;

Color color3 = base.Pen2.Color;

for (int i = fromIdx; i <= toIdx; i++)

{

Color barColor = chartControl.GetBarColor(bars, i);

int barPaintWidth = this.GetBarPaintWidth(barWidthUI);

double high = bars.GetHigh(i);

double low = bars.GetLow(i);

double open = bars.GetOpen(i);

double close = bars.GetClose(i);

int yByValue = chartControl.GetYByValue(bars, close);

double num14 = (i > 0) ? bars.GetClose(i - 1) : close;

chartControl.GetYByValue(bars, num14);

double num15 = (i > 0) ? bars.GetOpen(i - 1) : close;

if (i == 0)

{

high = bars.GetClose(i);

low = bars.GetClose(i);

}

int MyPeriod = 0;

int MyPeriod2 =0;

int MyBasePeriod = 0;

if(bars.Period.Value.ToString().Length == 6)

{

MyPeriod = Convert.ToInt32(bars.Period.Value.ToString().Subst ring(0, 2))-10;

MyPeriod2 = Convert.ToInt32(bars.Period.Value.ToString().Subst ring(2, 2))-10;

MyBasePeriod = Convert.ToInt32(bars.Period.Value.ToString().Subst ring(2, 2))-10;

}

else

{

MyPeriod = bars.Period.Value ;

MyPeriod2 = bars.Period.Value2 ;

MyBasePeriod = bars.Period.BasePeriodValue ;

}

int num17 = MyPeriod;//bars.Period.Value;

int num18 = MyPeriod2;//bars.Period.Value2;

double num19 = (num17 - num18) * bars.Instrument.MasterInstrument.TickSize;

int num10 = chartControl.GetYByValue(bars, open - num19);

int num11 = chartControl.GetYByValue(bars, open + num19);

open = (num14 > num15) ? (num14 - num19) : (num14 + num19);

int num9 = chartControl.GetYByValue(bars, open);

int num5 = chartControl.GetYByValue(bars, high);

int num7 = chartControl.GetYByValue(bars, low);

int xByBarIdx = chartControl.GetXByBarIdx(bars, i);

Color candleOutlineColor = chartControl.GetCandleOutlineColor(bars, i);

bool flag = chartControl.GetCandleOutlineColor(bars, i) != Color.Empty;

base.Pen.Color = color2;

if (barColor != Color.Empty)

{

base.Pen.Color = (candleOutlineColor != Color.Empty) ? candleOutlineColor : barColor;

}

else if (candleOutlineColor != Color.Empty)

{

base.Pen.Color = candleOutlineColor;

}

SolidBrush brush = (close >= open) ? this.upBrush : this.downBrush;

Color color = brush.Color;

if (barColor != Color.Empty)

{

brush.Color = barColor;

}

if (i != 0)

{

graphics.FillRectangle(brush, (int) ((xByBarIdx - (barPaintWidth / 2)) + 1), (int) (Math.Min(yByValue, num9) + 1), (int) (barPaintWidth - 1), (int) ((Math.Max(num9, yByValue) - Math.Min(yByValue, num9)) - 1));

}

if (barColor != Color.Empty)

{

brush.Color = color;

}

if (num14 > num15)

{

graphics.DrawRectangle(base.Pen, (xByBarIdx - (barPaintWidth / 2)) + (base.Pen.Width / 2f), (float) Math.Min(yByValue, num10), barPaintWidth - base.Pen.Width, (float) (Math.Max(num10, yByValue) - Math.Min(yByValue, num10)));

}

if (num14 < num15)

{

graphics.DrawRectangle(base.Pen, (xByBarIdx - (barPaintWidth / 2)) + (base.Pen.Width / 2f), (float) Math.Min(yByValue, num11), barPaintWidth - base.Pen.Width, (float) (Math.Max(num11, yByValue) - Math.Min(yByValue, num11)));

}

if (num14 > num15)

{

graphics.DrawLine(base.Pen, xByBarIdx - (barPaintWidth / 2), num10, xByBarIdx + (barPaintWidth / 2), num10);

}

if (num14 < num15)

{

graphics.DrawLine(base.Pen, xByBarIdx - (barPaintWidth / 2), num11, xByBarIdx + (barPaintWidth / 2), num11);

}

base.Pen2.Color = flag ? candleOutlineColor : color3;

if ((num5 < Math.Min(num10, yByValue)) && (num14 > num15))

{

graphics.DrawLine(base.Pen2, xByBarIdx, num5, xByBarIdx, Math.Min(num10, yByValue));

}

if ((num7 > Math.Max(num11, yByValue)) && (num14 < num15))

{

graphics.DrawLine(base.Pen2, xByBarIdx, num7, xByBarIdx, Math.Max(num11, yByValue));

}

if ((num5 < Math.Min(num11, yByValue)) && (num14 < num15))

{

graphics.DrawLine(base.Pen2, xByBarIdx, num5, xByBarIdx, Math.Min(num11, yByValue));

}

if ((num7 > Math.Max(num10, yByValue)) && (num14 > num15))

{

graphics.DrawLine(base.Pen2, xByBarIdx, num7, xByBarIdx, Math.Max(num10, yByValue));

}

}

base.Pen.Color = color2;

base.Pen2.Color = color3;

}

}

## Comment