/// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            double rsi0, rsi1, dar, tr, dv;

            if (CurrentBar <= StartBar)
            {
                return;
            }


            Value1.Set(EMA(RSI(rSI_Period, 3), sF)[0]);



            AtrRsi.Set(Math.Abs(Value1[1] - Value1[0]));

            MaAtrRsi.Set(EMA(AtrRsi, Wilders_Period)[0]);

            tr   = Value2[1];
            rsi1 = Value1[1];

            rsi0 = Value1[0];
            dar  = EMA(MaAtrRsi, Wilders_Period)[0] * 4.236;

            dv = tr;
            if (rsi0 < tr)
            {
                tr = rsi0 + dar;
                if (rsi1 < dv)
                {
                    if (tr > dv)
                    {
                        tr = dv;
                    }
                }
            }
            else if (rsi0 > tr)
            {
                tr = rsi0 - dar;
                if (rsi1 > dv)
                {
                    if (tr < dv)
                    {
                        tr = dv;
                    }
                }
            }
            Value2.Set(tr);


            //Change Colors
            PlotColors[0][0] = Line_01;
            PlotColors[1][0] = Line_02;
        }
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnCalculate()
        {
            double rsi0, rsi1, dar, tr, dv;

            if (ProcessingBarIndex <= StartBar)
            {
                return;
            }


            Value1.Set(EMA(RSI(rSI_Period, 3), sF)[0]);



            AtrRsi.Set(Math.Abs(Value1[1] - Value1[0]));

            MaAtrRsi.Set(EMA(AtrRsi, Wilders_Period)[0]);

            tr   = Value2[1];
            rsi1 = Value1[1];

            rsi0 = Value1[0];
            dar  = EMA(MaAtrRsi, Wilders_Period)[0] * 4.236;

            dv = tr;
            if (rsi0 < tr)
            {
                tr = rsi0 + dar;
                if (rsi1 < dv)
                {
                    if (tr > dv)
                    {
                        tr = dv;
                    }
                }
            }
            else if (rsi0 > tr)
            {
                tr = rsi0 - dar;
                if (rsi1 > dv)
                {
                    if (tr < dv)
                    {
                        tr = dv;
                    }
                }
            }
            Value2.Set(tr);


            //Change Colors
            PlotColors[0][0] = Line_01;
            PlotColors[1][0] = Line_02;

            //Drawing
            if (CrossAbove(Value1, Value2, 0))
            {
                AddChartArrowUp(ProcessingBarIndex.ToString(), true, 0, Low[0], Color.Green);
                lastcrossabove = Bars[0];
                AddChartText("lastsegmentpercentline" + Time[0], true, "QQI", Time[0], Low[0], 0, Color.Green, new Font("Arial", 8, FontStyle.Bold), StringAlignment.Far, HorizontalAlignment.Center, VerticalAlignment.Bottom, Color.Green, Color.White, 255);
            }
            else if (CrossBelow(Value1, Value2, 0))
            {
                AddChartArrowDown(ProcessingBarIndex.ToString(), true, 0, High[0], Color.Red);
                AddChartText("lastsegmentpercentline" + Time[0], true, "QQI", Time[0], High[0], 0, Color.Red, new Font("Arial", 8, FontStyle.Bold), StringAlignment.Far, HorizontalAlignment.Center, VerticalAlignment.Top, Color.Red, Color.White, 255);
            }

            if (lastcrossabove != null && CrossBelow(Value1, Value2, 0))
            {
                AddChartLine("drawaline" + Time[0], true, lastcrossabove.Time, lastcrossabove.Close, Time[0], Close[0], Color.Black, DashStyle.DashDotDot, 1);
            }
        }