Esempio n. 1
0
        public void SetParameters(params IndParameter[] parameters)
        {
            if (parameters[0] == "Timeframe")
            {
                if (m_timeframe != parameters[0])
                {
                    Unsubscribe();
                    m_timeframe     = parameters[0];
                    m_nexttimeframe = 0;
                }
            }

            if (parameters[0] == "Start")
            {
                IndParameter priorityParamater = parameters.FirstOrDefault(p => p == "Priority");

                if (priorityParamater.Value != null)
                {
                    m_unsubscriber = m_manager.AddTemporalObserver(this, m_token, null, priorityParamater);
                }
                else
                {
                    m_unsubscriber = m_manager.AddTemporalObserver(this, m_token);
                }
            }
        }
Esempio n. 2
0
 public IndSlice(TemporalContextManager manager, string token)
 {
     m_manager   = manager;
     m_token     = token;
     m_values    = new TemporalValue[0];
     m_columns   = new IndParameter[0];
     m_outTokens = new string[0];
 }
Esempio n. 3
0
        public void SetParameters(params IndParameter[] parameters)
        {
            if (parameters[0] == "Period")
            {
                if (m_period != parameters[0])
                {
                    Unsubscribe();
                    m_wma       = 0;
                    m_period    = parameters[0];
                    m_sumWeight = 0; for (int i = 1; i <= m_period; i++)
                    {
                        m_sumWeight += i;
                    }
                    m_window = new SortedSet <TemporalValue <double> >(new TemporalValueComparer <double>());
                }
            }

            if (parameters[0] == "Start")
            {
                IndParameter indexParamater    = parameters.FirstOrDefault(p => p == "Index");
                IndParameter priorityParamater = parameters.FirstOrDefault(p => p == "Priority");

                if (indexParamater.Value != null)
                {
                    m_index = indexParamater;
                    if (priorityParamater.Value != null)
                    {
                        m_unsubscriber = m_manager.AddTemporalObserver <double[]>(this, m_token, priorityParamater);
                    }
                    else
                    {
                        m_unsubscriber = m_manager.AddTemporalObserver <double[]>(this, m_token);
                    }
                }
                else
                {
                    if (priorityParamater.Value != null)
                    {
                        m_unsubscriber = m_manager.AddTemporalObserver <double>(this, m_token, null, priorityParamater);
                    }
                    else
                    {
                        m_unsubscriber = m_manager.AddTemporalObserver <double>(this, m_token);
                    }
                }
            }
        }
Esempio n. 4
0
        public void SetParameters(params IndParameter[] parameters)
        {
            if (parameters[0] == "Period")
            {
                if (m_period != parameters[0])
                {
                    Unsubscribe();

                    m_ema    = 0;
                    m_period = parameters[0];
                    m_KC     = (double)2 / (m_period + 1);
                    m_KE     = 1 - m_KC;
                }
            }

            if (parameters[0] == "Start")
            {
                IndParameter indexParamater    = parameters.FirstOrDefault(p => p == "Index");
                IndParameter priorityParamater = parameters.FirstOrDefault(p => p == "Priority");

                if (indexParamater.Value != null)
                {
                    m_index = indexParamater;
                    if (priorityParamater.Value != null)
                    {
                        m_unsubscriber = m_manager.AddTemporalObserver <double[]>(this, m_token, priorityParamater);
                    }
                    else
                    {
                        m_unsubscriber = m_manager.AddTemporalObserver <double[]>(this, m_token);
                    }
                }
                else
                {
                    if (priorityParamater.Value != null)
                    {
                        m_unsubscriber = m_manager.AddTemporalObserver <double>(this, m_token, null, priorityParamater);
                    }
                    else
                    {
                        m_unsubscriber = m_manager.AddTemporalObserver <double>(this, m_token);
                    }
                }
            }
        }
Esempio n. 5
0
        public void SetParameters(params IndParameter[] parameters)
        {
            if (parameters[0] == "N" && parameters[1] == "K")
            {
                if (_n != parameters[0] || _k != parameters[1])
                {
                    Unsubscribe();
                    _n = parameters[0];
                    _k = parameters[1];

                    m_indSMA = new IndSMA(m_manager, m_token);
                    m_indSMA.SetParameters(new IndParameter("Period", _n));
                }
            }

            if (parameters[0] == "Start")
            {
                IndParameter indexParamater    = parameters.FirstOrDefault(p => p == "Index");
                IndParameter priorityParamater = parameters.FirstOrDefault(p => p == "Priority");

                if (indexParamater.Value != null)
                {
                    m_indSMA.SetParameters(
                        new IndParameter("Start", true),
                        new IndParameter("Index", indexParamater),
                        new IndParameter("Priority", TemporalContextManager.InternalIndicatorPriority)
                        );
                }
                else
                {
                    m_indSMA.SetParameters(new IndParameter("Start", true),
                                           new IndParameter("Priority", TemporalContextManager.InternalIndicatorPriority));
                }

                if (priorityParamater.Value != null)
                {
                    m_unsubscriber = m_manager.AddTemporalObserver <double>(this, m_indSMA.Token, null, priorityParamater);
                }
                else
                {
                    m_unsubscriber = m_manager.AddTemporalObserver <double>(this, m_indSMA.Token);
                }
            }
        }
Esempio n. 6
0
        public void SetParameters(params IndParameter[] parameters)
        {
            if (parameters[0] == "Fast" && parameters[1] == "Slow" && parameters[2] == "Signal")
            {
                if (m_nf != parameters[0] || m_ns != parameters[1] || m_nsg != parameters[2])
                {
                    Unsubscribe();

                    m_nf  = parameters[0];
                    m_ns  = parameters[1];
                    m_nsg = parameters[2];
                }
            }

            if (parameters[0] == "Start")
            {
                IndParameter indexParamater    = parameters.FirstOrDefault(p => p == "Index");
                IndParameter priorityParamater = parameters.FirstOrDefault(p => p == "Priority");

                if (indexParamater.Value != null)
                {
                    m_line = new IndLine(m_manager, m_token, m_nf, m_ns, indexParamater);
                }
                else
                {
                    m_line = new IndLine(m_manager, m_token, m_nf, m_ns, -1);
                }

                m_signal = new IndSignal(m_manager, m_line.Token, m_nsg);

                if (priorityParamater.Value != null)
                {
                    m_unsubscriber = m_manager.AddTemporalObserver(this, m_signal.Token, null, priorityParamater);
                }
                else
                {
                    m_unsubscriber = m_manager.AddTemporalObserver(this, m_signal.Token);
                }
            }
        }
Esempio n. 7
0
 public bool Equals(IndParameter key)
 {
     return(String.CompareOrdinal(key.Name, Name) == 0 && key.Value.Equals(Value));
 }
Esempio n. 8
0
        public override bool Equals(object obj)
        {
            IndParameter key = (IndParameter)obj;

            return(String.CompareOrdinal(key.Name, Name) == 0 && key.Value.Equals(Value));
        }