//homes of the strategy
        private void OnInstrumentUpdate(Tick m_Tick)
        {
            //Debug::WriteLine( m_Tick.Price );
            //Add the tick object to the SortedList.
            m_TickList.Add(m_Tick);

            m_LongMA  = 0;
            m_ShortMA = 0;

            if (m_Go)
            {
                // If we already have a position on, and have either met our target or stop price, get out.
                if (m_Position > 0 && (m_Tick.Price > m_Target || m_Tick.Price < m_Stop))
                {
                    bool m_Bool = m_Instrument.EnterOrder("S", m_Qty, "TARGET/STOP OUT");
                }
                if (m_Position < 0 && (m_Tick.Price < m_Target || m_Tick.Price > m_Stop))
                {
                    bool m_Bool = m_Instrument.EnterOrder("B", m_Qty, "TARGET/STOP OUT");
                }

                if (m_TickList.Count > m_LongMATicks)
                {
                    //Calculate the long moving average.
                    for (int x = m_TickList.Count - m_LongMATicks; x <= m_TickList.Count - 1; x++)
                    {
                        m_LongMA += m_TickList[x].Price;
                    }
                    m_LongMA /= m_LongMATicks;

                    //Calculate the short moving average.
                    for (int x = m_TickList.Count - m_ShortMATicks; x <= m_TickList.Count - 1; x++)
                    {
                        m_ShortMA += m_TickList[x].Price;
                    }
                    m_ShortMA /= m_ShortMATicks;

                    // First time only and on reset, set initial state.
                    if (m_Start)
                    {
                        if (m_ShortMA > m_LongMA)
                        {
                            m_State = MA_State.ABOVE;
                        }
                        else
                        {
                            m_State = MA_State.BELOW;
                        }
                        m_Start = false;
                    }

                    // Has there been a crossover up?
                    if (m_ShortMA > m_LongMA && m_State == MA_State.BELOW)
                    {
                        // Change state.
                        m_State = MA_State.ABOVE;

                        // If we are already short, first get flat.
                        if (m_Position < 0)
                        {
                            m_Bool = m_Instrument.EnterOrder("B", m_Qty, "GET OUT");
                        }

                        //  Go long.
                        m_Bool = m_Instrument.EnterOrder("B", m_Qty, "OPEN");

                        // Set target price and stop loss price.
                        m_Target = m_Tick.Price + m_TargetTicks * m_Instrument.TickSize();
                        m_Stop   = m_Tick.Price - m_StopTicks * m_Instrument.TickSize();
                    }

                    // Has there been a crossover down?
                    if (m_ShortMA < m_LongMA && m_State == MA_State.ABOVE)
                    {
                        // Change state.
                        m_State = MA_State.BELOW;

                        // If we are already long, first get flat.
                        if (m_Position > 0)
                        {
                            m_Bool = m_Instrument.EnterOrder("S", m_Qty, "GET OUT");
                        }

                        // Go short.
                        m_Bool = m_Instrument.EnterOrder("S", m_Qty, "OPEN");

                        // Set target price and stop loss price.
                        m_Target = m_Tick.Price - m_TargetTicks * m_Instrument.TickSize();
                        m_Stop   = m_Tick.Price + m_StopTicks * m_Instrument.TickSize();
                    }
                }
            }
            //Send the data to the GUI.
            OnSystemUpdate(m_Tick.Price, m_Tick.Qty, m_LongMA, m_ShortMA, m_Target, m_Stop);
        }
        private void OnNotifyUpdate(InstrNotifyClass pNotify, InstrObjClass pInstr)
        {
            Tick m_Tick = new Tick(DateTime.Now, Convert.ToDouble(pInstr.get_Get("LAST")), Convert.ToDouble(pInstr.get_Get("LASTQTY")));

            OnInstrumentUpdate(m_Tick);
        }