or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-types.mdindex.mdmomentum-indicators.mdoverlay-indicators.mdspecialized-indicators.mdtrend-indicators.mdvolatility-indicators.mdvolume-indicators.md

specialized-indicators.mddocs/

0

# Specialized Indicators

1

2

Advanced and specialized technical indicators including mathematical functions, candlestick pattern recognition, correlation analysis, and proprietary indicators for sophisticated market analysis.

3

4

## Capabilities

5

6

### Correlation Analysis

7

8

Measures the correlation coefficient between two price series to identify relationships.

9

10

```python { .api }

11

def get_correlation(quotes_a: Iterable[Quote], quotes_b: Iterable[Quote], lookback_periods: int = 20):

12

"""

13

Correlation - measures relationship between two price series.

14

15

Args:

16

quotes_a (Iterable[Quote]): First price series

17

quotes_b (Iterable[Quote]): Second price series

18

lookback_periods (int): Number of periods for calculation (defaults to 20)

19

20

Returns:

21

CorrelationResults[CorrelationResult]: Collection of Correlation results

22

"""

23

```

24

25

### Beta Coefficient

26

27

Measures the volatility of a security relative to the overall market.

28

29

```python { .api }

30

def get_beta(eval_quotes: Iterable[Quote], market_quotes: Iterable[Quote], lookback_periods: int,

31

beta_type: BetaType = BetaType.STANDARD):

32

"""

33

Beta - measures security volatility relative to market.

34

35

Args:

36

eval_quotes (Iterable[Quote]): Security quotes to evaluate

37

market_quotes (Iterable[Quote]): Market benchmark quotes

38

lookback_periods (int): Number of periods for calculation

39

beta_type (BetaType): Type of beta calculation (defaults to STANDARD)

40

41

Returns:

42

BetaResults[BetaResult]: Collection of Beta results

43

"""

44

```

45

46

### Hurst Exponent

47

48

Measures the long-term memory and predictability of time series data.

49

50

```python { .api }

51

def get_hurst(quotes: Iterable[Quote], lookback_periods: int = 100):

52

"""

53

Hurst Exponent - measures long-term memory of time series.

54

55

Args:

56

quotes (Iterable[Quote]): Historical price quotes

57

lookback_periods (int): Number of periods for calculation (defaults to 100)

58

59

Returns:

60

HurstResults[HurstResult]: Collection of Hurst results

61

"""

62

```

63

64

### Slope and Linear Regression

65

66

Calculates slope and linear regression statistics for trend analysis.

67

68

```python { .api }

69

def get_slope(quotes: Iterable[Quote], lookback_periods: int):

70

"""

71

Slope - linear regression slope and statistics.

72

73

Args:

74

quotes (Iterable[Quote]): Historical price quotes

75

lookback_periods (int): Number of periods for regression

76

77

Returns:

78

SlopeResults[SlopeResult]: Collection of Slope results

79

"""

80

```

81

82

### Candlestick Patterns

83

84

#### Doji Pattern

85

86

Identifies Doji candlestick patterns indicating market indecision.

87

88

```python { .api }

89

def get_doji(quotes: Iterable[Quote]):

90

"""

91

Doji - identifies Doji candlestick patterns.

92

93

Args:

94

quotes (Iterable[Quote]): Historical price quotes

95

96

Returns:

97

CandleResults[CandleResult]: Collection of Doji pattern results

98

"""

99

```

100

101

#### Marubozu Pattern

102

103

Identifies Marubozu candlestick patterns indicating strong directional movement.

104

105

```python { .api }

106

def get_marubozu(quotes: Iterable[Quote]):

107

"""

108

Marubozu - identifies Marubozu candlestick patterns.

109

110

Args:

111

quotes (Iterable[Quote]): Historical price quotes

112

113

Returns:

114

CandleResults[CandleResult]: Collection of Marubozu pattern results

115

"""

116

```

117

118

### Advanced Mathematical Indicators

119

120

#### Fisher Transform

121

122

Transforms price data to approximate Gaussian normal distribution for better signal identification.

123

124

```python { .api }

125

def get_fisher_transform(quotes: Iterable[Quote], lookback_periods: int = 10):

126

"""

127

Fisher Transform - transforms prices to Gaussian distribution.

128

129

Args:

130

quotes (Iterable[Quote]): Historical price quotes

131

lookback_periods (int): Number of periods for calculation (defaults to 10)

132

133

Returns:

134

FisherTransformResults[FisherTransformResult]: Collection of Fisher Transform results

135

"""

136

```

137

138

#### Hilbert Transform Instantaneous Trendline

139

140

Uses Hilbert Transform to identify the instantaneous trendline.

141

142

```python { .api }

143

def get_ht_trendline(quotes: Iterable[Quote]):

144

"""

145

Hilbert Transform Instantaneous Trendline - identifies instantaneous trend.

146

147

Args:

148

quotes (Iterable[Quote]): Historical price quotes

149

150

Returns:

151

HtTrendlineResults[HtTrendlineResult]: Collection of HT Trendline results

152

"""

153

```

154

155

### Proprietary and Specialized Indicators

156

157

#### Elder Ray Index

158

159

Dr. Alexander Elder's indicator combining trend and momentum analysis.

160

161

```python { .api }

162

def get_elder_ray(quotes: Iterable[Quote], lookback_periods: int = 13):

163

"""

164

Elder Ray Index - combines trend and momentum analysis.

165

166

Args:

167

quotes (Iterable[Quote]): Historical price quotes

168

lookback_periods (int): EMA periods for calculation (defaults to 13)

169

170

Returns:

171

ElderRayResults[ElderRayResult]: Collection of Elder Ray results

172

"""

173

```

174

175

#### Price Relative Strength (PRS)

176

177

Compares the performance of one security relative to another.

178

179

```python { .api }

180

def get_prs(eval_quotes: Iterable[Quote], base_quotes: Iterable[Quote], lookback_periods: Optional[int] = None,

181

sma_periods: Optional[int] = None):

182

"""

183

Price Relative Strength (PRS) - compares security performance.

184

185

Args:

186

eval_quotes (Iterable[Quote]): Security quotes to evaluate

187

base_quotes (Iterable[Quote]): Base security quotes for comparison

188

lookback_periods (Optional[int]): Periods for momentum calculation

189

sma_periods (Optional[int]): SMA periods for smoothing

190

191

Returns:

192

PRSResults[PRSResult]: Collection of PRS results

193

"""

194

```

195

196

#### Balance of Power (BOP)

197

198

Measures the balance between buying and selling pressure.

199

200

```python { .api }

201

def get_bop(quotes: Iterable[Quote]):

202

"""

203

Balance of Power (BOP) - measures buying vs selling pressure.

204

205

Args:

206

quotes (Iterable[Quote]): Historical price quotes

207

208

Returns:

209

BOPResults[BOPResult]: Collection of BOP results

210

"""

211

```

212

213

#### Fractal Chaos Bands (FCB)

214

215

Bill Williams' fractal-based support and resistance levels.

216

217

```python { .api }

218

def get_fcb(quotes: Iterable[Quote], window_span: int = 2):

219

"""

220

Fractal Chaos Bands (FCB) - fractal-based support/resistance.

221

222

Args:

223

quotes (Iterable[Quote]): Historical price quotes

224

window_span (int): Window span for fractal identification (defaults to 2)

225

226

Returns:

227

FCBResults[FCBResult]: Collection of FCB results

228

"""

229

```

230

231

#### Stochastic Momentum Index (SMI)

232

233

Enhanced version of stochastic oscillator with additional smoothing.

234

235

```python { .api }

236

def get_smi(quotes: Iterable[Quote], lookback_periods: int = 13, first_smooth_periods: int = 25,

237

second_smooth_periods: int = 2, signal_periods: int = 9):

238

"""

239

Stochastic Momentum Index (SMI) - enhanced stochastic with smoothing.

240

241

Args:

242

quotes (Iterable[Quote]): Historical price quotes

243

lookback_periods (int): Lookback periods for stochastic (defaults to 13)

244

first_smooth_periods (int): First smoothing periods (defaults to 25)

245

second_smooth_periods (int): Second smoothing periods (defaults to 2)

246

signal_periods (int): Signal line EMA periods (defaults to 9)

247

248

Returns:

249

SMIResults[SMIResult]: Collection of SMI results

250

"""

251

```

252

253

#### Schaff Trend Cycle (STC)

254

255

Combines slow stochastic oscillator with MACD for enhanced trend detection.

256

257

```python { .api }

258

def get_stc(quotes: Iterable[Quote], cycle_periods: int = 10, fast_periods: int = 23, slow_periods: int = 50):

259

"""

260

Schaff Trend Cycle (STC) - combines stochastic with MACD.

261

262

Args:

263

quotes (Iterable[Quote]): Historical price quotes

264

cycle_periods (int): Cycle periods for calculation (defaults to 10)

265

fast_periods (int): Fast periods for MACD (defaults to 23)

266

slow_periods (int): Slow periods for MACD (defaults to 50)

267

268

Returns:

269

STCResults[STCResult]: Collection of STC results

270

"""

271

```

272

273

#### Zig Zag

274

275

Filters out small price movements to identify significant trends and reversals.

276

277

```python { .api }

278

def get_zig_zag(quotes: Iterable[Quote], percent_change: float = 5, end_type: EndType = EndType.CLOSE):

279

"""

280

Zig Zag - filters small movements to show significant trends.

281

282

Args:

283

quotes (Iterable[Quote]): Historical price quotes

284

percent_change (float): Minimum percentage change to identify pivot (defaults to 5)

285

end_type (EndType): Use CLOSE or HIGH_LOW prices (defaults to CLOSE)

286

287

Returns:

288

ZigZagResults[ZigZagResult]: Collection of Zig Zag results

289

"""

290

```

291

292

#### Vortex Indicator

293

294

Measures the relationship between closing prices and true range to identify trend changes.

295

296

```python { .api }

297

def get_vortex(quotes: Iterable[Quote], lookback_periods: int = 14):

298

"""

299

Vortex Indicator - measures relationship between close and true range.

300

301

Args:

302

quotes (Iterable[Quote]): Historical price quotes

303

lookback_periods (int): Number of periods for calculation (defaults to 14)

304

305

Returns:

306

VortexResults[VortexResult]: Collection of Vortex results

307

"""

308

```

309

310

#### Dynamic Momentum Index

311

312

Adaptive RSI that varies the lookback period based on market volatility.

313

314

```python { .api }

315

def get_dynamic(quotes: Iterable[Quote], lookback_periods: int = 14, k_factor: float = 0.5):

316

"""

317

Dynamic Momentum Index - adaptive RSI with variable periods.

318

319

Args:

320

quotes (Iterable[Quote]): Historical price quotes

321

lookback_periods (int): Base lookback periods (defaults to 14)

322

k_factor (float): Volatility adjustment factor (defaults to 0.5)

323

324

Returns:

325

DynamicResults[DynamicResult]: Collection of Dynamic results

326

"""

327

```

328

329

## Usage Examples

330

331

### Correlation Analysis for Portfolio Diversification

332

333

```python

334

from stock_indicators.indicators import get_correlation

335

336

# Analyze correlation between two securities

337

correlation_results = get_correlation(spy_quotes, stock_quotes, lookback_periods=60)

338

339

# Identify periods of high/low correlation

340

for result in correlation_results:

341

if result.correlation is not None:

342

if abs(result.correlation) > 0.8:

343

print(f"{result.date}: High correlation: {result.correlation:.3f}")

344

elif abs(result.correlation) < 0.3:

345

print(f"{result.date}: Low correlation: {result.correlation:.3f}")

346

```

347

348

### Candlestick Pattern Recognition

349

350

```python

351

from stock_indicators.indicators import get_doji, get_marubozu

352

from stock_indicators.indicators.common import Match

353

354

# Identify reversal patterns

355

doji_results = get_doji(quotes)

356

marubozu_results = get_marubozu(quotes)

357

358

# Look for strong pattern signals

359

for result in doji_results:

360

if result.match in [Match.BULL_CONFIRMED, Match.BEAR_CONFIRMED]:

361

print(f"{result.date}: Strong Doji signal: {result.match}")

362

363

for result in marubozu_results:

364

if result.match in [Match.BULL_CONFIRMED, Match.BEAR_CONFIRMED]:

365

print(f"{result.date}: Strong Marubozu signal: {result.match}")

366

```

367

368

### Additional Specialized Functions

369

370

#### Williams Fractal

371

372

Retrospective price pattern that identifies central high or low points over a lookback window.

373

374

```python { .api }

375

def get_fractal(quotes: Iterable[Quote], window_span: int = 2, end_type: EndType = EndType.HIGH_LOW):

376

"""

377

Williams Fractal - identifies high/low price patterns.

378

379

Args:

380

quotes (Iterable[Quote]): Historical price quotes

381

window_span (int): Number of periods to left and right of evaluation (defaults to 2)

382

end_type (EndType): High/Low pattern type (defaults to HIGH_LOW)

383

384

Returns:

385

FractalResults[FractalResult]: Collection of fractal results

386

"""

387

```

388

389

#### Heikin-Ashi

390

391

Modified candlestick pattern that uses prior day data for smoothing.

392

393

```python { .api }

394

def get_heikin_ashi(quotes: Iterable[Quote]):

395

"""

396

Heikin-Ashi - smoothed candlestick representation.

397

398

Args:

399

quotes (Iterable[Quote]): Historical price quotes

400

401

Returns:

402

HeikinAshiResults[HeikinAshiResult]: Collection of Heikin-Ashi results

403

"""

404

```

405

406

#### Gator Oscillator

407

408

Companion to the Alligator indicator showing convergence and divergence of the smoothed moving averages.

409

410

```python { .api }

411

def get_gator(quotes: Iterable[Quote], jaw_periods: int = 13, teeth_periods: int = 8, lips_periods: int = 5):

412

"""

413

Gator Oscillator - shows Alligator jaw, teeth, and lips convergence/divergence.

414

415

Args:

416

quotes (Iterable[Quote]): Historical price quotes

417

jaw_periods (int): Jaw line periods (defaults to 13)

418

teeth_periods (int): Teeth line periods (defaults to 8)

419

lips_periods (int): Lips line periods (defaults to 5)

420

421

Returns:

422

GatorResults[GatorResult]: Collection of Gator oscillator results

423

"""

424

```

425

426

#### True Range

427

428

Measures volatility capturing gaps and limits between periods.

429

430

```python { .api }

431

def get_tr(quotes: Iterable[Quote]):

432

"""

433

True Range - measures period-to-period volatility.

434

435

Args:

436

quotes (Iterable[Quote]): Historical price quotes

437

438

Returns:

439

TrResults[TrResult]: Collection of True Range results

440

"""

441

```

442

443

#### Renko Charts

444

445

Price-based charting that filters time and focuses only on price movements.

446

447

```python { .api }

448

def get_renko(quotes: Iterable[Quote], brick_size: float):

449

"""

450

Renko - price-based charting with fixed brick size.

451

452

Args:

453

quotes (Iterable[Quote]): Historical price quotes

454

brick_size (float): Fixed brick size for Renko chart

455

456

Returns:

457

RenkoResults[RenkoResult]: Collection of Renko results

458

"""

459

460

def get_renko_atr(quotes: Iterable[Quote], atr_periods: int = 14):

461

"""

462

Renko - price-based charting with ATR-based brick sizing.

463

464

Args:

465

quotes (Iterable[Quote]): Historical price quotes

466

atr_periods (int): Periods for ATR-based brick sizing (defaults to 14)

467

468

Returns:

469

RenkoResults[RenkoResult]: Collection of Renko results

470

"""

471

```

472

473

#### Standard Deviation Channels

474

475

Creates channels based on standard deviation from a linear regression line.

476

477

```python { .api }

478

def get_stdev_channels(quotes: Iterable[Quote], lookback_periods: int = 20, standard_deviations: float = 2):

479

"""

480

Standard Deviation Channels - regression line with deviation bands.

481

482

Args:

483

quotes (Iterable[Quote]): Historical price quotes

484

lookback_periods (int): Number of periods for calculation (defaults to 20)

485

standard_deviations (float): Number of standard deviations for bands (defaults to 2)

486

487

Returns:

488

StdevChannelsResults[StdevChannelsResult]: Collection of channel results

489

"""

490

```

491

492

#### Pivot Point Analysis

493

494

```python { .api }

495

def get_pivots(quotes: Iterable[Quote], left_span: int = 2, right_span: int = 2, max_trend_periods: int = 20):

496

"""

497

Pivots - identifies pivot points for support/resistance analysis.

498

499

Args:

500

quotes (Iterable[Quote]): Historical price quotes

501

left_span (int): Left span periods (defaults to 2)

502

right_span (int): Right span periods (defaults to 2)

503

max_trend_periods (int): Maximum trend periods (defaults to 20)

504

505

Returns:

506

PivotsResults[PivotsResult]: Collection of pivot results

507

"""

508

509

def get_rolling_pivots(quotes: Iterable[Quote], window_periods: int = 11, offset_periods: int = 9):

510

"""

511

Rolling Pivots - rolling window pivot analysis.

512

513

Args:

514

quotes (Iterable[Quote]): Historical price quotes

515

window_periods (int): Rolling window periods (defaults to 11)

516

offset_periods (int): Offset periods (defaults to 9)

517

518

Returns:

519

RollingPivotsResults[RollingPivotsResult]: Collection of rolling pivot results

520

"""

521

```