Mariner Backtesting - TA-LIB On-Neck Pattern

CDLONNECK

 

 integer = CDLONNECK(open, high, low, close)
  • 0 = No Signal
  • -100 = Bearish Signal
  • 100 = Bullish Signal

Candlestick Plot

On-Neck Pattern

 

Working Example

from cloudquant.interfaces import Strategy
from collections import OrderedDict
import ktgfunc
import talib

class WE_CDLONNECK(Strategy):

    def on_start(self, md, order, service, account):
        # symbol and timestamp
        print(self.symbol + ":  " + service.time_to_string(service.system_time))
        daily_bars = md.bar.daily(start=-100)
        close = daily_bars.close
        high = daily_bars.high
        low = daily_bars.low
        open = daily_bars.open
        integer = talib.CDLONNECK(open, high, low, close)

        # get the date values
        dates = service._context.market._storage.market_hours.keys()
        dateList = []
        for date in dates:
           dateList.append(str(date.strftime('%Y-%m-%d')))
        dates = sorted(dateList, reverse=True)[1:101]
        dates.sort()

        dict = OrderedDict()
        dict['date'] = dates
        dict['open'] = open
        dict['high'] = high
        dict['low'] = low
        dict['close'] = close
        dict['integer'] = integer
        symbol = 'CDLONNECK: ' + self.symbol
        print ktgfunc.talib_table(symbol, 1, dict)

Console

GOOG:  2016-11-04 09:30:00.000000
CDLONNECK: GOOG
Input Output
date open high low close integer
2016-06-15 719.00 722.98 717.31 718.92 0.00
2016-06-16 714.91 716.65 703.26 710.36 0.00
2016-06-17 708.65 708.82 688.45 691.72 0.00
2016-06-20 698.77 702.48 693.41 693.71 0.00
2016-06-21 698.40 702.77 692.01 695.94 0.00
2016-06-22 699.06 700.86 693.08 697.46 0.00
2016-06-23 697.45 701.95 687.00 701.87 0.00
2016-06-24 675.17 689.40 673.45 675.22 0.00
2016-06-27 671.00 672.30 663.28 668.26 0.00
2016-06-28 678.97 680.33 673.00 680.04 0.00
2016-06-29 683.00 687.43 681.41 684.11 0.00
2016-06-30 685.47 692.32 683.65 692.10 0.00
2016-07-01 692.20 700.65 692.13 699.21 0.00
2016-07-05 696.06 696.94 688.88 694.49 0.00
2016-07-06 689.98 701.68 689.09 697.77 0.00
2016-07-07 698.08 698.20 688.22 695.36 0.00
2016-07-08 699.50 705.71 696.43 705.63 0.00
2016-07-11 708.05 716.51 707.24 715.09 0.00
2016-07-12 719.12 722.94 715.91 720.64 0.00
2016-07-13 723.62 724.00 716.85 716.98 0.00
2016-07-14 721.58 722.21 718.03 720.95 0.00
2016-07-15 725.73 725.74 719.05 719.85 0.00
2016-07-18 722.71 736.13 721.19 733.78 0.00
2016-07-19 729.89 736.99 729.00 736.96 0.00
2016-07-20 737.33 742.13 737.10 741.19 0.00
2016-07-21 740.36 741.69 735.83 738.63 0.00
2016-07-22 741.86 743.24 736.56 742.74 0.00
2016-07-25 740.67 742.61 737.50 739.77 0.00
2016-07-26 739.04 741.69 734.27 738.42 0.00
2016-07-27 738.28 744.46 737.00 741.77 0.00
2016-07-28 747.04 748.65 739.30 745.91 0.00
2016-07-29 772.71 778.55 766.77 768.79 0.00
2016-08-01 761.09 780.43 761.09 772.88 0.00
2016-08-02 768.69 775.84 767.85 771.07 0.00
2016-08-03 767.18 773.21 766.82 773.18 0.00
2016-08-04 772.22 774.07 768.79 771.61 0.00
2016-08-05 773.78 783.04 772.34 782.22 0.00
2016-08-08 782.00 782.63 778.09 781.76 0.00
2016-08-09 781.10 788.94 780.57 784.26 0.00
2016-08-10 783.75 786.81 782.78 784.68 0.00
2016-08-11 785.00 789.75 782.97 784.85 0.00
2016-08-12 781.50 783.40 780.40 783.22 0.00
2016-08-15 783.75 787.49 780.11 782.44 0.00
2016-08-16 780.30 780.98 773.44 777.14 0.00
2016-08-17 777.32 780.81 773.53 779.91 0.00
2016-08-18 780.01 782.86 777.00 777.50 0.00
2016-08-19 775.00 777.10 773.13 775.42 0.00
2016-08-22 773.27 774.54 770.05 772.15 0.00
2016-08-23 775.48 776.44 771.78 772.08 0.00
2016-08-24 770.58 774.50 767.07 769.64 0.00
2016-08-25 767.00 771.89 763.18 769.41 0.00
2016-08-26 769.00 776.08 765.85 769.54 0.00
2016-08-29 768.74 774.99 766.61 772.15 0.00
2016-08-30 769.33 774.47 766.84 769.09 0.00
2016-08-31 767.01 769.09 765.38 767.05 0.00
2016-09-01 769.25 771.02 764.30 768.78 0.00
2016-09-02 773.01 773.92 768.41 771.46 0.00
2016-09-06 773.45 782.00 771.00 780.08 0.00
2016-09-07 780.00 782.73 776.20 780.35 0.00
2016-09-08 778.59 780.35 773.58 775.32 0.00
2016-09-09 770.10 773.24 759.66 759.66 0.00
2016-09-12 755.13 770.29 754.00 769.02 0.00
2016-09-13 764.48 766.22 755.80 759.69 0.00
2016-09-14 759.61 767.68 759.11 762.49 0.00
2016-09-15 762.89 773.80 759.96 771.76 0.00
2016-09-16 769.75 769.75 764.66 768.88 0.00
2016-09-19 772.42 774.00 764.44 765.70 0.00
2016-09-20 769.00 773.33 768.53 771.41 0.00
2016-09-21 772.66 777.16 768.30 776.22 0.00
2016-09-22 780.00 789.85 778.44 787.21 0.00
2016-09-23 786.59 788.93 784.15 786.90 0.00
2016-09-26 782.74 782.74 773.07 774.21 0.00
2016-09-27 775.50 785.99 774.31 783.01 0.00
2016-09-28 777.85 781.81 774.97 781.56 0.00
2016-09-29 781.44 785.80 774.23 775.01 0.00
2016-09-30 776.33 780.94 774.09 777.29 0.00
2016-10-03 774.25 776.07 769.50 772.56 0.00
2016-10-04 776.03 778.71 772.89 776.43 0.00
2016-10-05 779.31 782.07 775.65 776.47 0.00
2016-10-06 779.00 780.48 775.54 776.86 0.00
2016-10-07 779.66 779.66 770.75 775.08 0.00
2016-10-10 777.71 789.38 775.87 785.94 0.00
2016-10-11 786.66 792.28 780.58 783.07 0.00
2016-10-12 783.76 788.13 782.06 786.14 0.00
2016-10-13 781.22 781.22 773.00 778.19 0.00
2016-10-14 781.65 783.95 776.00 778.53 0.00
2016-10-17 779.80 785.85 777.50 779.96 0.00
2016-10-18 787.85 801.61 785.57 795.26 0.00
2016-10-19 798.86 804.63 797.64 801.56 0.00
2016-10-20 803.30 803.97 796.03 796.97 0.00
2016-10-21 795.00 799.50 794.00 799.37 0.00
2016-10-24 804.90 815.18 804.82 813.11 0.00
2016-10-25 816.68 816.68 805.14 807.67 0.00
2016-10-26 806.34 806.98 796.32 799.07 0.00
2016-10-27 801.00 803.49 791.50 795.35 0.00
2016-10-28 808.35 815.49 793.59 795.37 0.00
2016-10-31 795.47 796.86 784.00 784.54 0.00
2016-11-01 782.89 789.49 775.54 783.61 -100.00
2016-11-02 778.20 781.65 763.45 768.70 0.00
2016-11-03 767.25 769.95 759.03 762.13 0.00