/// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            bool condition1, condition2, condition3;

            //condition1 = (EMA(shortMA)[0] >= EMA(longMA)[0]) || (EMA(medMA)[0] >= EMA(longMA)[0]);
            condition1 = (EMA(shortMA)[0] >= EMA(longMA)[0]) && (EMA(medMA)[0] >= EMA(longMA)[0]);

            condition2 = RSI(2, 2)[0] < 15;

            condition3 = Close[0] > EMA(longMA)[0];

            if (condition1 && condition2 && condition3)
            {
                if (alertOn > 0)
                {
                    Alert("Long", NinjaTrader.Cbi.Priority.Medium, "BuySignal", "Alert1.wav", 300, Color.Black, Color.Yellow);
                }

                Buy.Set(Low[0]);
            }

            bool condition4, condition5, condition6;

            condition4 = (EMA(shortMA)[0] <= EMA(longMA)[0]) && (EMA(medMA)[0] <= EMA(longMA)[0]);

            condition5 = RSI(2, 2)[0] > 85;

            condition6 = Close[0] < EMA(longMA)[0];

            if (condition4 && condition5 && condition6)
            {
                if (alertOn > 0)
                {
                    Alert("Short", NinjaTrader.Cbi.Priority.Medium, "SellSignal", "Alert1.wav", 300, Color.Black, Color.Yellow);
                }
                Sell.Set(High[0]);
            }
        }