CDLCOUNTERATTACK
integer = CDLCOUNTERATTACK(open, high, low, close)
- 0 = No Signal
- -100 = Bearish Signal
- 100 = Bullish Signal
Candlestick Plot
Working Example
from cloudquant.interfaces import Strategy
from collections import OrderedDict
import ktgfunc
import talib
class WE_CDLCOUNTERATTACK(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.CDLCOUNTERATTACK(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 = 'CDLCOUNTERATTACK: ' + self.symbol
print ktgfunc.talib_table(symbol, 1, dict)
Console
GOOG: 2016-02-11 09:30:00.000000
CDLCOUNTERATTACK: GOOG | |||||
---|---|---|---|---|---|
Input | Output | ||||
date | open | high | low | close | integer |
2015-09-18 | 636.79 | 640.00 | 627.02 | 629.25 | 0.00 |
2015-09-21 | 634.40 | 636.49 | 625.94 | 635.44 | 0.00 |
2015-09-22 | 627.00 | 627.55 | 615.43 | 622.69 | 0.00 |
2015-09-23 | 622.05 | 628.93 | 620.00 | 622.36 | 0.00 |
2015-09-24 | 616.64 | 627.32 | 612.40 | 625.80 | 0.00 |
2015-09-25 | 629.77 | 629.77 | 611.00 | 611.97 | 0.00 |
2015-09-28 | 610.34 | 614.60 | 589.38 | 594.89 | 0.00 |
2015-09-29 | 597.28 | 605.00 | 590.22 | 594.97 | 0.00 |
2015-09-30 | 603.28 | 608.76 | 600.73 | 608.42 | 0.00 |
2015-10-01 | 608.37 | 612.09 | 599.85 | 611.29 | 0.00 |
2015-10-02 | 607.20 | 627.34 | 603.13 | 626.91 | 0.00 |
2015-10-05 | 632.00 | 643.01 | 627.00 | 641.47 | 0.00 |
2015-10-06 | 638.84 | 649.25 | 636.53 | 645.44 | 0.00 |
2015-10-07 | 649.24 | 650.61 | 632.15 | 642.36 | 0.00 |
2015-10-08 | 641.36 | 644.45 | 625.56 | 639.16 | 0.00 |
2015-10-09 | 640.00 | 645.99 | 635.32 | 643.61 | 0.00 |
2015-10-12 | 642.09 | 648.50 | 639.01 | 646.67 | 0.00 |
2015-10-13 | 643.15 | 657.81 | 643.15 | 652.30 | 0.00 |
2015-10-14 | 653.21 | 659.39 | 648.85 | 651.16 | 0.00 |
2015-10-15 | 654.66 | 663.13 | 654.46 | 661.74 | 0.00 |
2015-10-16 | 664.11 | 664.97 | 657.20 | 662.20 | 0.00 |
2015-10-19 | 661.18 | 666.82 | 659.58 | 666.10 | 0.00 |
2015-10-20 | 664.04 | 664.72 | 644.20 | 650.28 | 0.00 |
2015-10-21 | 654.15 | 655.87 | 641.73 | 642.61 | 0.00 |
2015-10-22 | 646.70 | 657.80 | 644.01 | 651.79 | 0.00 |
2015-10-23 | 727.50 | 730.00 | 701.50 | 702.00 | 0.00 |
2015-10-26 | 701.55 | 719.15 | 701.26 | 712.78 | 0.00 |
2015-10-27 | 707.38 | 713.62 | 704.55 | 708.49 | 0.00 |
2015-10-28 | 707.33 | 712.98 | 703.08 | 712.95 | 0.00 |
2015-10-29 | 710.50 | 718.26 | 710.01 | 716.92 | 0.00 |
2015-10-30 | 715.73 | 718.00 | 710.05 | 710.81 | 0.00 |
2015-11-02 | 711.06 | 721.62 | 705.85 | 721.11 | 0.00 |
2015-11-03 | 718.86 | 724.65 | 714.72 | 722.16 | 0.00 |
2015-11-04 | 722.00 | 733.10 | 721.90 | 728.11 | 0.00 |
2015-11-05 | 729.47 | 739.48 | 729.47 | 731.25 | 0.00 |
2015-11-06 | 731.50 | 735.41 | 727.01 | 733.76 | 0.00 |
2015-11-09 | 730.20 | 734.71 | 719.43 | 724.89 | 0.00 |
2015-11-10 | 724.40 | 730.59 | 718.50 | 728.32 | 0.00 |
2015-11-11 | 732.46 | 741.00 | 730.23 | 735.40 | 0.00 |
2015-11-12 | 731.00 | 737.80 | 728.65 | 731.23 | 0.00 |
2015-11-13 | 729.17 | 731.15 | 716.73 | 717.00 | 0.00 |
2015-11-16 | 715.60 | 729.49 | 711.33 | 728.96 | 0.00 |
2015-11-17 | 729.29 | 731.84 | 723.03 | 725.30 | 0.00 |
2015-11-18 | 727.58 | 741.41 | 727.00 | 740.00 | 0.00 |
2015-11-19 | 738.74 | 742.00 | 737.43 | 738.41 | 0.00 |
2015-11-20 | 746.53 | 757.92 | 743.00 | 756.60 | 0.00 |
2015-11-23 | 757.45 | 762.71 | 751.82 | 755.98 | 0.00 |
2015-11-24 | 752.00 | 755.28 | 737.63 | 748.28 | 0.00 |
2015-11-25 | 748.14 | 752.00 | 746.06 | 748.15 | 0.00 |
2015-11-27 | 748.46 | 753.41 | 747.49 | 750.26 | 0.00 |
2015-11-30 | 748.81 | 754.93 | 741.27 | 742.60 | 0.00 |
2015-12-01 | 747.11 | 768.95 | 746.70 | 767.04 | 0.00 |
2015-12-02 | 768.90 | 775.96 | 758.96 | 762.38 | 0.00 |
2015-12-03 | 766.01 | 768.99 | 745.63 | 752.54 | 0.00 |
2015-12-04 | 753.10 | 768.49 | 750.00 | 766.81 | 0.00 |
2015-12-07 | 767.77 | 768.73 | 755.09 | 763.25 | 0.00 |
2015-12-08 | 757.89 | 764.80 | 754.20 | 762.37 | 0.00 |
2015-12-09 | 759.17 | 764.23 | 737.00 | 751.61 | 0.00 |
2015-12-10 | 752.85 | 755.85 | 743.83 | 749.46 | 0.00 |
2015-12-11 | 741.16 | 745.71 | 736.75 | 738.87 | 0.00 |
2015-12-14 | 741.79 | 748.73 | 724.17 | 747.77 | 0.00 |
2015-12-15 | 753.00 | 758.08 | 743.01 | 743.40 | 0.00 |
2015-12-16 | 750.00 | 760.59 | 739.43 | 758.09 | 0.00 |
2015-12-17 | 762.42 | 762.68 | 749.00 | 749.43 | 0.00 |
2015-12-18 | 746.51 | 754.13 | 738.15 | 739.31 | 0.00 |
2015-12-21 | 746.13 | 750.00 | 740.00 | 747.77 | 0.00 |
2015-12-22 | 751.65 | 754.85 | 745.53 | 750.00 | 0.00 |
2015-12-23 | 753.47 | 754.21 | 744.00 | 750.31 | 0.00 |
2015-12-24 | 749.55 | 751.35 | 746.62 | 748.40 | 0.00 |
2015-12-28 | 752.92 | 762.99 | 749.52 | 762.51 | 0.00 |
2015-12-29 | 766.69 | 779.98 | 766.43 | 776.60 | 0.00 |
2015-12-30 | 776.60 | 777.60 | 766.90 | 771.00 | 0.00 |
2015-12-31 | 769.50 | 769.50 | 758.34 | 758.88 | 0.00 |
2016-01-04 | 743.00 | 744.06 | 731.26 | 741.84 | 0.00 |
2016-01-05 | 746.45 | 752.00 | 738.64 | 742.58 | 0.00 |
2016-01-06 | 730.00 | 747.18 | 728.92 | 743.62 | 0.00 |
2016-01-07 | 730.31 | 738.50 | 719.06 | 726.39 | 0.00 |
2016-01-08 | 731.45 | 733.23 | 713.00 | 714.47 | 0.00 |
2016-01-11 | 716.61 | 718.85 | 703.54 | 716.03 | 0.00 |
2016-01-12 | 721.68 | 728.75 | 717.32 | 726.07 | 0.00 |
2016-01-13 | 730.20 | 734.74 | 698.61 | 700.56 | 0.00 |
2016-01-14 | 705.38 | 721.92 | 689.10 | 714.72 | 0.00 |
2016-01-15 | 692.29 | 706.74 | 685.37 | 694.45 | 0.00 |
2016-01-19 | 703.30 | 709.98 | 693.41 | 701.79 | 0.00 |
2016-01-20 | 688.61 | 706.85 | 673.26 | 698.45 | 0.00 |
2016-01-21 | 702.18 | 719.19 | 694.46 | 706.59 | 0.00 |
2016-01-22 | 723.60 | 728.13 | 720.12 | 725.25 | 0.00 |
2016-01-25 | 723.58 | 729.68 | 710.01 | 711.67 | 0.00 |
2016-01-26 | 713.85 | 718.28 | 706.48 | 713.04 | 0.00 |
2016-01-27 | 713.67 | 718.23 | 694.39 | 699.99 | 0.00 |
2016-01-28 | 722.22 | 733.69 | 712.35 | 730.96 | 0.00 |
2016-01-29 | 731.53 | 744.99 | 726.80 | 742.95 | 0.00 |
2016-02-01 | 750.46 | 757.86 | 743.27 | 752.00 | 0.00 |
2016-02-02 | 784.50 | 789.87 | 764.65 | 764.65 | 0.00 |
2016-02-03 | 770.22 | 774.50 | 720.50 | 726.95 | 0.00 |
2016-02-04 | 722.81 | 727.00 | 701.86 | 708.01 | 0.00 |
2016-02-05 | 703.87 | 703.99 | 680.15 | 683.57 | 0.00 |
2016-02-08 | 667.85 | 684.03 | 663.06 | 682.74 | 100.00 |
2016-02-09 | 672.32 | 699.90 | 668.77 | 678.11 | 0.00 |
2016-02-10 | 686.86 | 701.31 | 682.13 | 684.12 | 0.00 |