Esempio n. 1
0
        public void add(Bar bar)
        {
            m_bars.Add(bar);
            if (m_bars.Count > m_maximumBars)
            {
                m_bars.Remove(m_bars[0]);
            }

            if (m_bars.Count >= m_minimumBars)
            {
                m_sentiment = Sentiment.NEUTRAL;
                if (m_bars[1].Low <m_bars[0].Low &&
                                   m_bars[1].Close> m_bars[0].Close)
                {
                    if (ClosesInTopQuarter(m_bars[2]))
                    {
                        m_sentiment = Sentiment.BULLISH;
                    }
                }
                else if (m_bars[1].High >= m_bars[0].High &&
                         m_bars[1].Close <= m_bars[0].Close)
                {
                    if (ClosesInBottomQuarter(m_bars[2]))
                    {
                        m_sentiment = Sentiment.BEARISH;
                    }
                }
            }
        }
Esempio n. 2
0
        public void add(Bar bar)
        {
            m_bars.Add(bar);
            if (m_bars.Count > m_maximumBars)
            {
                m_bars.Remove(m_bars[0]);
            }

            if (m_bars.Count >= m_minimumBars)
            {
                m_sentiment = Sentiment.NEUTRAL;

                if (m_bars[0].Close >= (m_bars[0].Low + (m_bars[0].High - m_bars[0].Low) / 2) &&
                    m_bars[1].Close >= (m_bars[1].Low + (m_bars[1].High - m_bars[1].Low) / 2) &&
                    ClosesInTopQuarter(m_bars[2])
                    )
                {
                    m_sentiment = Sentiment.BULLISH;
                }
                else if (m_bars[0].Close <= (m_bars[0].Low + (m_bars[0].High - m_bars[0].Low) / 2) &&
                         m_bars[1].Close >= (m_bars[1].Low + (m_bars[1].High - m_bars[1].Low) / 2) &&
                         m_bars[2].Close <= (m_bars[2].Low + (m_bars[2].High - m_bars[2].Low) / 4)
                         )
                {
                    m_sentiment = Sentiment.BEARISH;
                }
            }
        }
Esempio n. 3
0
        public void add(Bar bar)
        {
            m_bars.Add(bar);
            if (m_bars.Count > m_maximumBars)
            {
                m_bars.Remove(m_bars[0]);
            }

            if (m_bars.Count >= m_minimumBars)
            {
                m_sentiment = Sentiment.NEUTRAL;

                if (m_bars[0].High <m_bars[1].High && m_bars[0].Low> m_bars[1].Low)
                {
                    if (m_bars[1].Close >= m_bars[0].High)
                    {
                        m_sentiment = Sentiment.BULLISH;
                    }
                    else if (m_bars[1].Close <= m_bars[0].Low)
                    {
                        m_sentiment = Sentiment.BEARISH;
                    }
                }
            }
        }
Esempio n. 4
0
        public void add(Bar bar)
        {
            m_bars.Add(bar);
            if (m_bars.Count > m_maximumBars)
            {
                m_bars.Remove(m_bars[0]);
            }

            if (m_bars.Count >= m_minimumBars)
            {
                m_sentiment = Sentiment.NEUTRAL;

                int a = 0, b = 1, d = 1, e = 1;

                double ahigh = m_bars[a].High;
                int    size  = Math.Min(8, m_bars.Count);

                while (b < size)
                {
                    if (m_bars[a].Low > m_bars[b].Low && m_bars[b].High < ahigh)
                    {
                        break;
                    }
                    ++b;
                }
                // d must take out the high the preceeding bar
                d = b + 1;     // start at b
                while (d < size)
                {
                    if (m_bars[d].High < ahigh && m_bars[d - 1].High < ahigh && m_bars[d - 1].High < m_bars[d].High)
                    {
                        break;
                    }
                    ++d;
                }

                // e must take out the low of the preceeding bar
                // and close below the previous bar's close
                // and close below its own open price

                e = d + 1;

                while (e < size)
                {
                    Bar rece = m_bars[e];
                    Bar recf = m_bars[e - 1];
                    if (rece.Low < recf.Low &&  // take low of prev bare
                        rece.Close < recf.Close &&         // close below prev bar
                        rece.Close < rece.Open &&         // close down
                        rece.High < ahigh && recf.High < ahigh)
                    {
                        m_sentiment = Sentiment.BEARISH;
                        return;
                    }
                    ++e;
                }
            }
        }
Esempio n. 5
0
        public void add(Bar bar)
        {
            m_bars.Add(bar);
            if (m_bars.Count > m_maximumBars)
            {
                m_bars.Remove(m_bars[0]);
            }

            if (m_bars.Count >= m_minimumBars)
            {
                m_sentiment = Sentiment.NEUTRAL;

                int a = 0, b = 1, d = 1, e = 1;

                while (b < 9 && b < m_bars.Count)
                {
                    if (m_bars[1].High <m_bars[b].High && m_bars[b].Low> m_bars[a].Low)
                    {
                        break;
                    }
                    ++b;
                }

                d = b + 1;
                while (d < 9 && d < m_bars.Count)
                {
                    if (m_bars[d - 1].Low > m_bars[d].Low && m_bars[d].Low > m_bars[a].Low && m_bars[d - 1].Low > m_bars[a].Low)
                    {
                        break;
                    }
                    ++d;
                }

                e = d + 1;
                while (e < 9 && e < m_bars.Count)
                {
                    if (m_bars[e].High > m_bars[e - 1].High && m_bars[e].Close > m_bars[e - 1].Close && m_bars[e].Close > m_bars[e].Open && m_bars[e].Low > m_bars[a].Low && m_bars[e - 1].Low > m_bars[a].Low)
                    {
                        m_sentiment = Sentiment.BULLISH;
                        return;
                    }
                    ++e;
                }
            }
        }
Esempio n. 6
0
        public void add(Bar bar)
        {
            m_bars.Add(bar);

            if (m_bars.Count > m_maximumBars)
            {
                m_bars.Remove(m_bars[0]);
            }

            if (m_bars.Count >= m_minimumBars)
            {
                m_sentiment = Sentiment.NEUTRAL;

                bool[] reversals = { false, false, false, false, false, false };

                int   end      = (m_bars.Count < 6 ? m_bars.Count : 6) - 1;
                int[] complete = { 0, 0 };

                for (int n = 0; n < end; ++n)
                {
                    Bar      rn    = m_bars[n];
                    Bar      rn1   = m_bars[n + 1];
                    double[] high  = { rn.High, rn1.High };
                    double[] low   = { rn.Low, rn1.Low };
                    double[] close = { rn.Close, rn1.Close };

                    if (close[1] >= high[1] - 0.05 && close[0] <= low[0] + 0.05)
                    {
                        reversals[0] = true;
                        if (n + 1 > complete[0])
                        {
                            complete[0] = n + 1;
                        }
                    }
                    else if (close[0] >= high[0] - 0.05 && close[1] <= low[0] + 0.05)
                    {
                        reversals[3] = true;
                        if (n + 1 > complete[1])
                        {
                            complete[1] = n + 1;
                        }
                    }

                    if (low[1] < low[0] && close[1] > close[0])
                    {
                        reversals[1] = true;
                        if (n + 1 > complete[0])
                        {
                            complete[0] = n + 1;
                        }
                    }
                    else if (high[1] >= high[0] && close[1] <= close[0])
                    {
                        reversals[4] = true;
                        if (n + 1 > complete[1])
                        {
                            complete[1] = n + 1;
                        }
                    }

                    if (high[0] < high[1] && low[0] > low[1])
                    {
                        if (close[1] >= high[0])
                        {
                            reversals[2] = true;
                            if (n + 1 > complete[0])
                            {
                                complete[0] = n + 1;
                            }
                        }
                    }
                    else if (high[0] < high[1] && low[0] > low[1])
                    {
                        if (close[1] <= low[0])
                        {
                            reversals[5] = true;
                            if (n + 1 > complete[1])
                            {
                                complete[1] = n + 1;
                            }
                        }
                    }

                    if ((reversals[0] && (reversals[1] || reversals[2])) || (reversals[1] && (reversals[0] || reversals[2])) || (reversals[2] && (reversals[0] || reversals[1])))
                    {
                        reversals[0] = reversals[3];
                        reversals[1] = reversals[1];
                        reversals[2] = reversals[2];
                        m_sentiment  = Sentiment.BULLISH;
                        return;
                    }
                    else if ((reversals[3] && (reversals[4] || reversals[5])) || (reversals[4] && (reversals[3] || reversals[5])) || (reversals[5] && (reversals[3] || reversals[4])))
                    {
                        reversals[0] = reversals[3];
                        reversals[1] = reversals[4];
                        reversals[2] = reversals[5];
                        m_sentiment  = Sentiment.BEARISH;
                        return;
                    }
                    else
                    {
                        reversals[0] = reversals[1] = reversals[2] = false;
                    }
                }
            }
        }
Esempio n. 7
0
 public void init(Security security)
 {
     m_bars      = new List <Bar>();
     m_sentiment = Sentiment.INVALID;
 }