Beispiel #1
0
        private void Falling()
        {
            double limit;

            while (closeRate < (limit = (openRate - wickoSize)
                                        .ToRoundedRate(Symbol)))
            {
                var wicko = GetNewWicko(
                    openRate, highRate, limit, limit);

                lastWicko = wicko;

                OnWicko?.Invoke(this, new WickoArgs(wicko));

                openOn   = closeOn;
                openRate = limit;
                highRate = limit;
            }
        }
Beispiel #2
0
 public WickoArgs(Wicko wicko)
 {
     Wicko = wicko;
 }
Beispiel #3
0
        public void HandleTick(Tick tick)
        {
            var rate = tick.ToRate(rateToUse);

            if (firstTick)
            {
                firstTick = false;

                openOn    = tick.TickOn;
                closeOn   = tick.TickOn;
                openRate  = rate;
                highRate  = rate;
                lowRate   = rate;
                closeRate = rate;
            }
            else
            {
                closeOn = tick.TickOn;

                if (rate > highRate)
                {
                    highRate = rate;
                }

                if (rate < lowRate)
                {
                    lowRate = rate;
                }

                closeRate = rate;

                if (closeRate > openRate)
                {
                    if (lastWicko == null ||
                        (lastWicko.Trend == Trend.Rising))
                    {
                        Rising();

                        return;
                    }

                    var limit = (lastWicko.OpenRate + wickoSize)
                                .ToRoundedRate(Symbol);

                    if (closeRate > limit)
                    {
                        var wicko = GetNewWicko(
                            lastWicko.OpenRate, limit, lowRate, limit);

                        lastWicko = wicko;

                        OnWicko?.Invoke(this, new WickoArgs(wicko));

                        openOn   = closeOn;
                        openRate = limit;
                        lowRate  = limit;

                        Rising();
                    }
                }
                else if (closeRate < openRate)
                {
                    if (lastWicko == null ||
                        (lastWicko.Trend == Trend.Falling))
                    {
                        Falling();

                        return;
                    }

                    var limit = (lastWicko.OpenRate - wickoSize)
                                .ToRoundedRate(Symbol);

                    if (closeRate < limit)
                    {
                        var wicko = GetNewWicko(
                            lastWicko.OpenRate, highRate, limit, limit);

                        lastWicko = wicko;

                        OnWicko?.Invoke(this, new WickoArgs(wicko));

                        openOn   = closeOn;
                        openRate = limit;
                        highRate = limit;

                        Falling();
                    }
                }
            }
        }