CDL3LINESTRIKE
Three-Line Strike
integer = CDL3LINESTRIKE(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_CDL3LINESTRIKE(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.CDL3LINESTRIKE(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 = 'CDL3LINESTRIKE: ' + self.symbol
print ktgfunc.talib_table(symbol, 1, dict)
Console
YHOO: 2015-03-02 09:30:00.000000
CDL3LINESTRIKE: YHOO | |||||
---|---|---|---|---|---|
Input | Output | ||||
date | open | high | low | close | integer |
2014-10-06 | 41.20 | 41.73 | 41.04 | 41.52 | 0.00 |
2014-10-07 | 41.06 | 41.29 | 40.78 | 40.93 | 0.00 |
2014-10-08 | 41.00 | 41.29 | 40.10 | 41.08 | 0.00 |
2014-10-09 | 40.90 | 41.25 | 40.42 | 41.10 | 0.00 |
2014-10-10 | 40.73 | 41.07 | 39.59 | 39.60 | 0.00 |
2014-10-13 | 39.52 | 40.07 | 38.29 | 38.38 | 0.00 |
2014-10-14 | 38.66 | 39.00 | 37.71 | 37.97 | 0.00 |
2014-10-15 | 37.27 | 38.08 | 36.20 | 37.82 | 0.00 |
2014-10-16 | 36.95 | 38.50 | 36.92 | 38.12 | 0.00 |
2014-10-17 | 38.74 | 38.98 | 38.31 | 38.45 | 0.00 |
2014-10-20 | 38.47 | 39.40 | 38.25 | 39.28 | 0.00 |
2014-10-21 | 39.65 | 40.48 | 39.46 | 40.18 | 0.00 |
2014-10-22 | 42.42 | 42.88 | 41.77 | 42.00 | 0.00 |
2014-10-23 | 42.40 | 42.83 | 42.26 | 42.60 | 0.00 |
2014-10-24 | 42.53 | 43.65 | 42.40 | 43.50 | 0.00 |
2014-10-27 | 43.31 | 44.80 | 43.29 | 44.70 | 0.00 |
2014-10-28 | 45.01 | 46.15 | 44.88 | 45.87 | 0.00 |
2014-10-29 | 45.94 | 45.98 | 45.13 | 45.43 | 0.00 |
2014-10-30 | 45.21 | 45.84 | 45.13 | 45.63 | 0.00 |
2014-10-31 | 46.16 | 46.52 | 45.67 | 46.05 | 0.00 |
2014-11-03 | 46.05 | 46.72 | 45.93 | 46.34 | 0.00 |
2014-11-04 | 45.99 | 47.13 | 45.74 | 47.08 | 0.00 |
2014-11-05 | 47.59 | 48.28 | 47.32 | 47.46 | 0.00 |
2014-11-06 | 47.37 | 47.98 | 46.60 | 47.93 | 0.00 |
2014-11-07 | 47.90 | 48.67 | 47.86 | 48.55 | 0.00 |
2014-11-10 | 48.80 | 49.63 | 48.79 | 49.41 | 0.00 |
2014-11-11 | 48.57 | 49.18 | 48.10 | 49.05 | 0.00 |
2014-11-12 | 49.33 | 50.63 | 49.22 | 50.60 | 0.00 |
2014-11-13 | 50.95 | 51.17 | 49.95 | 50.50 | 0.00 |
2014-11-14 | 50.52 | 51.95 | 50.47 | 51.75 | 0.00 |
2014-11-17 | 51.83 | 52.42 | 50.94 | 52.37 | 0.00 |
2014-11-18 | 52.28 | 52.62 | 51.34 | 51.75 | 0.00 |
2014-11-19 | 51.24 | 51.37 | 50.00 | 50.58 | 0.00 |
2014-11-20 | 50.60 | 52.23 | 50.27 | 51.25 | 0.00 |
2014-11-21 | 51.99 | 52.25 | 50.99 | 51.04 | 0.00 |
2014-11-24 | 51.25 | 51.83 | 51.07 | 51.83 | 0.00 |
2014-11-25 | 52.00 | 52.19 | 51.60 | 51.72 | 0.00 |
2014-11-26 | 51.56 | 52.26 | 51.52 | 51.93 | 0.00 |
2014-11-28 | 51.87 | 52.00 | 51.64 | 51.74 | 0.00 |
2014-12-01 | 51.51 | 51.51 | 49.66 | 50.10 | 0.00 |
2014-12-02 | 50.27 | 51.12 | 50.01 | 50.67 | 0.00 |
2014-12-03 | 50.71 | 50.97 | 50.20 | 50.28 | 0.00 |
2014-12-04 | 50.19 | 50.67 | 49.90 | 50.41 | 0.00 |
2014-12-05 | 51.03 | 51.25 | 50.51 | 50.99 | 0.00 |
2014-12-08 | 50.52 | 50.90 | 49.22 | 49.62 | 0.00 |
2014-12-09 | 48.75 | 50.53 | 48.29 | 50.51 | 0.00 |
2014-12-10 | 50.33 | 50.69 | 49.19 | 49.21 | 0.00 |
2014-12-11 | 49.54 | 50.58 | 49.43 | 49.94 | 0.00 |
2014-12-12 | 49.54 | 51.17 | 49.48 | 50.24 | 0.00 |
2014-12-15 | 50.42 | 50.92 | 49.50 | 49.82 | 0.00 |
2014-12-16 | 49.50 | 50.08 | 48.81 | 48.85 | 0.00 |
2014-12-17 | 49.02 | 50.25 | 48.90 | 50.12 | 0.00 |
2014-12-18 | 50.93 | 51.15 | 50.44 | 50.91 | 0.00 |
2014-12-19 | 51.06 | 51.47 | 50.83 | 50.88 | 0.00 |
2014-12-22 | 50.99 | 51.60 | 50.95 | 51.15 | 0.00 |
2014-12-23 | 51.46 | 51.46 | 49.93 | 50.02 | 0.00 |
2014-12-24 | 50.19 | 50.92 | 50.19 | 50.65 | 0.00 |
2014-12-26 | 50.65 | 51.06 | 50.61 | 50.86 | 0.00 |
2014-12-29 | 50.67 | 51.01 | 50.51 | 50.53 | 0.00 |
2014-12-30 | 50.35 | 51.27 | 50.35 | 51.22 | 0.00 |
2014-12-31 | 51.54 | 51.68 | 50.46 | 50.51 | 0.00 |
2015-01-02 | 50.66 | 50.78 | 49.47 | 50.17 | 0.00 |
2015-01-05 | 49.71 | 49.88 | 48.91 | 49.13 | 0.00 |
2015-01-06 | 49.20 | 49.73 | 48.33 | 49.21 | 0.00 |
2015-01-07 | 49.62 | 49.64 | 48.51 | 48.59 | 0.00 |
2015-01-08 | 48.99 | 50.23 | 48.72 | 50.23 | 0.00 |
2015-01-09 | 50.28 | 50.41 | 49.62 | 49.72 | 0.00 |
2015-01-12 | 49.92 | 49.93 | 48.56 | 48.80 | 0.00 |
2015-01-13 | 49.15 | 49.48 | 47.40 | 48.30 | 0.00 |
2015-01-14 | 48.40 | 48.40 | 47.07 | 47.51 | 0.00 |
2015-01-15 | 47.54 | 47.75 | 46.20 | 46.23 | 0.00 |
2015-01-16 | 46.06 | 46.59 | 45.85 | 46.47 | 0.00 |
2015-01-20 | 46.79 | 47.89 | 46.77 | 47.63 | 0.00 |
2015-01-21 | 47.71 | 48.38 | 47.32 | 48.18 | 0.00 |
2015-01-22 | 48.43 | 49.08 | 48.01 | 48.89 | 0.00 |
2015-01-23 | 48.74 | 49.23 | 48.63 | 48.95 | 0.00 |
2015-01-26 | 49.57 | 49.79 | 49.07 | 49.44 | 0.00 |
2015-01-27 | 49.14 | 49.28 | 47.66 | 47.99 | 0.00 |
2015-01-28 | 49.80 | 50.32 | 46.30 | 46.46 | 0.00 |
2015-01-29 | 43.56 | 43.80 | 41.80 | 43.73 | 0.00 |
2015-01-30 | 43.73 | 44.85 | 43.51 | 43.99 | 0.00 |
2015-02-02 | 44.43 | 44.76 | 43.88 | 44.69 | 0.00 |
2015-02-03 | 45.10 | 45.25 | 44.38 | 44.70 | 0.00 |
2015-02-04 | 44.80 | 44.97 | 43.88 | 44.04 | 0.00 |
2015-02-05 | 44.08 | 44.26 | 43.03 | 43.54 | 0.00 |
2015-02-06 | 43.57 | 43.66 | 42.67 | 42.94 | 0.00 |
2015-02-09 | 42.61 | 43.15 | 42.54 | 42.57 | 0.00 |
2015-02-10 | 42.90 | 43.17 | 42.66 | 43.07 | 0.00 |
2015-02-11 | 43.18 | 43.26 | 42.76 | 42.96 | 0.00 |
2015-02-12 | 43.07 | 44.16 | 42.86 | 43.92 | 0.00 |
2015-02-13 | 44.12 | 44.59 | 44.00 | 44.42 | 0.00 |
2015-02-17 | 44.37 | 44.54 | 43.35 | 43.53 | 0.00 |
2015-02-18 | 43.56 | 43.82 | 43.30 | 43.65 | 0.00 |
2015-02-19 | 43.65 | 44.42 | 43.50 | 44.37 | 0.00 |
2015-02-20 | 44.30 | 44.36 | 43.76 | 44.11 | 0.00 |
2015-02-23 | 43.99 | 43.99 | 43.42 | 43.53 | 0.00 |
2015-02-24 | 43.45 | 43.52 | 42.91 | 43.38 | 0.00 |
2015-02-25 | 43.21 | 44.72 | 43.21 | 44.43 | -100.00 |
2015-02-26 | 44.60 | 44.76 | 44.26 | 44.45 | 0.00 |
2015-02-27 | 44.38 | 44.57 | 44.04 | 44.28 | 0.00 |