protected override void OnBarUpdate() { if (CurrentBar < 20) { return; } lastBar = CurrentBar - 1; // Cnnvert Military Time to Ninja Time ninja_Start_Time = startTime * 100; ninja_End_Time = endTime * 100; ninja_IB_End_Time = IBendTime * 100; // find globex range if (ToTime(Time[0]) <= ninja_Start_Time || ToTime(Time[0]) >= ninja_End_Time) { counter = counter + 1; gxHigh = MAX(High, counter)[0]; gxLow = MIN(Low, counter)[0]; gxMid = ((gxHigh - gxLow) / 2) + gxLow; gxMidBarsAgo = counter / 2; } // Session Start if (ToTime(Time[1]) <= ninja_Start_Time && ToTime(Time[0]) >= ninja_Start_Time) { counter = 0; rthCounter = 0; ibCounter = 0; open_D = Open[0]; openingBarNum = CurrentBar; } // Find RTH Range if (ToTime(Time[0]) >= ninja_Start_Time && ToTime(Time[0]) < ninja_End_Time) { rthCounter = rthCounter + 1; todaysHigh = MAX(High, rthCounter)[0]; todaysLow = MIN(Low, rthCounter)[0]; } // Find IB Range if (ToTime(Time[0]) >= ninja_Start_Time && ToTime(Time[0]) < ninja_IB_End_Time) { ibCounter = ibCounter + 1; ibHigh = MAX(High, ibCounter)[0]; ibLow = MIN(Low, ibCounter)[0]; ibMid = ((ibHigh - ibLow) / 2) + ibLow; if (ibCounter > 2) { ibMidBarsAgo = ibCounter / 2; } else { ibMidBarsAgo = ibCounter; } } // Session End if (ToTime(Time[1]) <= ninja_End_Time && ToTime(Time[0]) >= ninja_End_Time) { yHigh = todaysHigh; yLow = todaysLow; todaysClose = Close[0]; yMid = ((yHigh - yLow) / 2) + yLow; openingGxBarNum = CurrentBar; } // show prior day Hi and Low // RTH if (ToTime(Time[0]) >= ninja_Start_Time && ToTime(Time[0]) < ninja_End_Time) { latestRTHbar = CurrentBar - openingBarNum; if (yLow != 0 && yMid != 0 && yHigh != 0) { RemoveDrawObject("RthBoxU" + lastBar); RemoveDrawObject("RthBoxL" + lastBar); Draw.Rectangle(this, "RthBoxU" + CurrentBar.ToString(), true, latestRTHbar, yMid, 0, yHigh, Brushes.Transparent, Brushes.DarkBlue, 20); Draw.Rectangle(this, "RthBoxL" + CurrentBar.ToString(), true, latestRTHbar, yLow, 0, yMid, Brushes.Transparent, Brushes.DarkRed, 20); } } // plot globex if (ToTime(Time[0]) <= ninja_Start_Time || ToTime(Time[0]) >= ninja_End_Time) // Find GX Hi/Lo { lastGxBar = CurrentBar - openingGxBarNum; RemoveDrawObject("GxBox" + lastBar); Draw.Rectangle(this, "GxBox" + CurrentBar.ToString(), true, lastGxBar, gxLow, 0, gxHigh, Brushes.Goldenrod, Brushes.Goldenrod, 10); } // Draw arrow from GX mid to OR mid if (ToTime(Time[0]) >= ninja_Start_Time && ToTime(Time[0]) < ninja_IB_End_Time) { RemoveDrawObject("ibArrow" + lastBar); if (ibMid > gxMid) { Draw.ArrowLine(this, "ibArrow" + CurrentBar.ToString(), gxMidBarsAgo + rthCounter, gxMid, ibMidBarsAgo, ibMid, Brushes.DodgerBlue, DashStyleHelper.Solid, 6); } else { Draw.ArrowLine(this, "ibArrow" + CurrentBar.ToString(), gxMidBarsAgo + rthCounter, gxMid, ibMidBarsAgo, ibMid, Brushes.DarkRed, DashStyleHelper.Solid, 6); } } }