Example #1
0
        private void DrawVerticalLine(DateTime time)
        {
            try{
                int rand = new Random().Next(10000);
                var IRB  = (indi_or_strat as NinjaTrader.Gui.NinjaScript.IndicatorRenderBase);
                try { IRB.RemoveDrawObject("Debugger_CurrentBarVLine" + randLast); } catch {}

                NinjaTrader.NinjaScript.DrawingTools.Draw.VerticalLine(indi_or_strat, "Debugger_CurrentBarVLine" + rand, time, Brushes.Orange, DashStyleHelper.DashDot, 2);
                // in 5 seconds, remove it
                System.Threading.Timer timer = null;
                timer = new System.Threading.Timer(
                    (object state) => {
                    IRB.RemoveDrawObject("Debugger_CurrentBarVLine" + rand);
                    timer.Dispose();
                }
                    , null                    // no state required
                    , TimeSpan.FromSeconds(5) // Do it in x seconds
                    , TimeSpan.FromMilliseconds(-1)
                    );                        // don't repeat
                randLast = rand;
            }
            catch (Exception ex)
            {
                indi_or_strat.Print(ex.ToString());
            }
        }
        public static void DrawVerticalLineBlinking(NinjaTrader.NinjaScript.NinjaScriptBase indi_or_strat, int idx)
        {
            try{
                int rand = new Random().Next(100000);
                RemoveDrawObject(indi_or_strat, "Debugger_CurrentBarVLine" + randLast);
                int  clicked_Bar = indi_or_strat.CurrentBars[0] - idx + (indi_or_strat.BarsPeriod.BarsPeriodType == BarsPeriodType.Day ? 1 : 0);                //don't know, on daily was displaced
                Bars bars        = indi_or_strat.BarsArray[0];
                if (clicked_Bar + 1 >= indi_or_strat.Bars.Count)
                {
                    return;                     //I donno, I couldn't make it work on last bar, so just hide it
                }
                //NinjaTrader.NinjaScript.DrawingTools.Draw.VerticalLine(indi_or_strat, "Debugger_CurrentBarVLine"+rand, idx, Brushes.Orange, DashStyleHelper.DashDot, 2);
                var time = bars.GetTime(clicked_Bar).AddSeconds(-ChartInSeconds(indi_or_strat) / 6);
                NinjaTrader.NinjaScript.DrawingTools.Draw.VerticalLine(indi_or_strat, "Debugger_CurrentBarVLine" + rand, time, Brushes.Orange, DashStyleHelper.DashDot, 2);

                // in 5 seconds, remove it
                System.Threading.Timer timer = null;
                timer = new System.Threading.Timer(
                    (object state) => {
                    RemoveDrawObject(indi_or_strat, "Debugger_CurrentBarVLine" + rand);
                    timer.Dispose();
                }
                    , null                    // no state required
                    , TimeSpan.FromSeconds(5) // Do it in x seconds
                    , TimeSpan.FromMilliseconds(-1)
                    );                        // don't repeat

                randLast = rand;
            }
            catch (Exception ex)
            {
                indi_or_strat.Print(ex.ToString());
            }
        }