Built-in Strategies Catalogue
The following strategies are included with Algolang. Use algo strategies -l -i to see descriptions and inputs for each.
Trend Following
| Strategy | Description |
|---|
macrossover | Simple moving average crossover |
goldencross | Golden cross (50/200 day MA crossover) |
trendfollow | Trend following system |
momo | Momentum strategy |
highenergy | High Energy: long-only triple confirmation for energy futures (momentum + consecutive higher highs + Hurst persistence filter) |
highenergy — High Energy
High Energy is a long-only daily strategy for energy futures (@CL, @HO, @RB) designed to capitalise on energy bull runs. It requires all three conditions to align before entering:
- Medium-term momentum: close must be above the close from XLength bars ago
- Consecutive higher highs: at least ConsecHighs consecutive bars where high > previous high
- Hurst persistence: the Hurst exponent (single-scale R/S at HurstPeriod) must be in the persistent zone (above HurstMin, at or below HurstMax)
There are two exit mechanisms. The signal exit fires when the close breaks above the highest high of the previous ExitLookback bars, signaling that the momentum extension has played out. The time-based exit (MaxHoldBars) cuts positions that haven’t triggered the signal exit within a set number of bars — winning trades typically resolve in ~11 bars, while losers that linger rarely recover. Both exits allow immediate re-entry on the same bar if entry conditions are met.
| Input | Type | Default | Description |
|---|
XLength | int | 20 | Lookback for medium-term momentum comparison (close > close[XLength]) |
ConsecHighs | int | 3 | Minimum consecutive higher highs required for micro-momentum confirmation |
HurstPeriod | int | 24 | Window size for Hurst exponent calculation (single-scale R/S, approximates CompositeHurst) |
HurstMin | float64 | 0.50 | Lower bound for Hurst persistent zone (exclusive); at or below = random walk |
HurstMax | float64 | 0.65 | Upper bound for Hurst persistent zone (inclusive); above = overextended |
ExitLookback | int | 35 | Number of prior bars for highest-high exit (shifted by 1 to exclude current bar) |
MaxHoldBars | int | 50 | Exit after this many bars. Winning trades resolve in ~11 bars; losers held 50+ bars rarely recover. Set to 0 to disable (better for equity indices) |
Breakout
| Strategy | Description |
|---|
breakout | Channel breakout |
keybreak | Key bar breakout |
kbt | Key Breakout Triangle (Dow theory symmetrical triangles) |
kbt2 | Key Breakout Triangle 2 (symmetrical triangles with swing-based ratcheting stops) |
tri | Triangle formation detection and swing point diagnostics |
corebreak | Core breakout strategy |
kbt2 Inputs
| Input | Type | Default | Description |
|---|
Level | int | 1 | SwingPoints hierarchical level |
IsPartial | bool | true | Allow partial triangles |
MaxBarsNoPivot | int | 5 | Exit if pivot not reached within N bars |
MinRatchetATR | float64 | 1.0 | Minimum stop distance in ATR multiples |
MinRewardRisk | float64 | 1.0 | Minimum reward/risk ratio (pivot distance vs ATR) |
TrendAligned | bool | true | Require trade direction to match MA50 slope |
MinADX | float64 | 25 | Minimum ADX for trend strength (0=disabled) |
ADXPeriod | int | 14 | ADX lookback period (5–50) |
VolContractMin | float64 | 0.5 | Minimum ATR4/ATR20 ratio (0=disabled) |
VolContractMax | float64 | 1.3 | Maximum ATR4/ATR20 ratio (0=disabled) |
IndexLongOnly | bool | true | Only allow long trades on index futures |
IsDynamicSize | bool | true | Enable risk-parity position sizing based on equity and point value (floor 1, ceiling 4 contracts) |
RiskPips | int | 25 | Risk per trade in basis points (25 = 0.25%); only used when IsDynamicSize is true |
WaitBarsAfterLoser | int | 0 | 0–20 |
IsDebug | bool | false | Enable debug output |
kbt Inputs
| Input | Type | Default | Description |
|---|
SwingMode | string | SSC | Swing chart mode: SSC (Simple) or NSC (Normal) |
IsPartial | bool | true | Allow partial triangles |
IsDynamicSize | bool | true | Enable risk-parity position sizing based on equity and point value (floor 1, ceiling 4 contracts) |
RiskPips | int | 25 | Risk per trade in basis points (25 = 0.25%); only used when IsDynamicSize is true |
WaitBarsAfterLoser | int | 0 | 0–20 |
IsDebug | bool | false | Enable debug output |
keybreak Inputs
| Input | Type | Default | Description |
|---|
Mode | string | notset | Swing chart mode: KBD (daily) or KBW (weekly) |
Exit | string | notset | Exit mode: 1 (immediate-term), 5 (short-term), M (medium-term) |
DisasterStopPct | float64 | 0.0 | Disaster stop as percentage of current close (0=disabled) |
IsDynamicSize | bool | true | Enable risk-parity position sizing based on equity and point value (floor 1, ceiling 4 contracts) |
RiskPips | int | 25 | Risk per trade in basis points (25 = 0.25%); only used when IsDynamicSize is true |
WaitBarsAfterLoser | int | 0 | 0–20 |
tri Inputs
| Input | Type | Default | Description |
|---|
SwingMode | string | SSC | Swing chart mode: SSC (Simple) or NSC (Normal) |
IsDebug | bool | false | Print swing highs/lows with dates as they are detected |
Mean Reversion
| Strategy | Description |
|---|
viper | Log-return z-score mean reversion: fades abnormally large moves |
ratchet | Kaufman Efficiency Ratio mean reversion |
whiplash | 2-day runs long/short with VIX-based volatility filter (Yang 2013) |
blackbird | Long convexity tail-risk hedge: frequent small losses, large gains during crashes |
slowcrash | Long convexity for grinding selloffs: persistent VIX elevation + price weakness |
meanrevert | RSI and Bollinger-based mean reversion |
rsi2 | 2-period RSI mean reversion |
ranger | Range trading |
viper Inputs
A mean reversion strategy that uses z-scores of logarithmic returns to detect and fade abnormally large price moves. Instead of simple returns, it computes ln(close/close[n]) which is additive over time and symmetric for gains and losses. The current log return is normalized into a z-score against a rolling window, and when the z-score is extreme (e.g., below -2.0 standard deviations), the strategy enters long expecting a snap-back to the mean.
The strategy operates purely on price data (no VIX dependency) and is applicable to any instrument. Optional filters include a trend SMA filter, RSI confirmation, and limit entries. Exits include z-score reversion (the primary exit), RSI reversion, time stops, and ATR-based risk management.
| Input | Type | Default | Description |
|---|
LogReturnLen | int | 1 | Lookback for log return: ln(close/close[n]). 1 = single-bar shocks, 5-10 = multi-day moves |
ZScoreLookback | int | 60 | Rolling window for computing mean and standard deviation of log returns |
ZScoreEntryLong | float64 | -2.0 | Z-score threshold for long entry (negative = sharp drop) |
ZScoreEntryShort | float64 | 2.0 | Z-score threshold for short entry (positive = sharp rally) |
UseTrendFilter | bool | false | Restrict longs to uptrends and shorts to downtrends |
UseShortTrendFilter | bool | true | Restrict shorts to downtrends only (close < SMA). Suppresses unprofitable short entries during bull markets |
TrendSMALength | int | 200 | SMA period for trend filter |
UseRSIConfirm | bool | false | Require extreme RSI before entry |
RSILength | int | 2 | RSI lookback period |
RSIEntryLong | float64 | 15 | Enter long only when RSI below this level |
RSIEntryShort | float64 | 85 | Enter short only when RSI above this level |
UseLimitEntry | bool | false | Use limit orders at ATR offset instead of market orders |
LimitOffsetATR | float64 | 0.5 | ATR offset from close for limit entry price |
CooldownBars | int | 3 | Minimum bars between entries |
UseVolRegimeFilter | bool | false | Suppress entries when ATR > VolRegimeATRMult * rolling ATR average. Caution: also cuts the biggest winners |
VolRegimeATRAvgLen | int | 60 | Lookback for the ATR’s rolling average |
VolRegimeATRMult | float64 | 1.8 | ATR multiplier threshold for suppression |
ZScoreExitLong | float64 | 0.0 | Exit long when z-score reverts above this level |
ZScoreExitShort | float64 | 0.0 | Exit short when z-score reverts below this level |
RSIExitLong | float64 | 70 | Exit long when RSI rises above this level |
RSIExitShort | float64 | 30 | Exit short when RSI drops below this level |
MaxHoldBars | int | 5 | Maximum bars to hold a position (0 = disable). Mean-reversion edge decays fast — 82% of trades resolve within 3 bars |
ATRStopLength | int | 14 | ATR lookback for stop loss calculation |
ATRStopMultiplier | float64 | 1.5 | ATR multiplier for stop loss distance. Caps individual losses while time stop handles non-reverting trades |
UseBreakEven | bool | false | Activate break-even stop after profit reaches BreakEvenATR * ATR |
BreakEvenATR | float64 | 1.0 | ATR multiple for break-even activation |
UseProfitTarget | bool | false | Exit at a fixed profit target. Disabled by default — z-score reversion is the primary profit-taking exit |
ProfitTargetATR | float64 | 2.0 | ATR multiple for profit target |
UseDollarTrailing | bool | false | Trail stop from peak profit |
TrailingATR | float64 | 1.5 | ATR multiple for trailing stop distance |
UseStopTightening | bool | true | Tighten stop after N bars. If the trade hasn’t reverted by bar 3, the thesis is weakening |
StopTightenAfter | int | 3 | Tighten stop after this many bars |
TightenedStopATR | float64 | 0.75 | ATR multiple for tightened stop |
IsDynamicSize | bool | false | Position sizing by risk pips and point value |
RiskPips | int | 25 | Equity risk per trade in basis points (25 = 0.25%) |
ratchet Inputs
| Input | Type | Default | Description |
|---|
ERLength | int | 5 | Kaufman Efficiency Ratio lookback period |
ERThreshold | float64 | 0.618 | Minimum ER to qualify as a sharp move (0..1) |
MomentumLength | int | 5 | Momentum lookback for move direction |
RSILength | int | 2 | RSI period for entry/exit timing |
RSIEntryLong | float64 | 20 | Enter long when RSI below this level |
RSIEntryShort | float64 | 80 | Enter short when RSI above this level |
UseTrendFilter | bool | true | Require trend alignment (close vs SMA) |
TrendLength | int | 200 | SMA period for trend filter |
RSIExitLong | float64 | 70 | Exit long when RSI above this level |
RSIExitShort | float64 | 30 | Exit short when RSI below this level |
MaxHoldBars | int | 10 | Maximum bars to hold a position |
ATRStopLength | int | 20 | ATR lookback for stop loss calculation |
ATRStopMultiplier | float64 | 3 | ATR multiplier for stop loss distance |
IsDynamicSize | bool | true | Position sizing by risk pips and point value (1-4 contracts) |
RiskPips | int | 25 | Equity risk per trade in basis points (25 = 0.25%) |
UseBreakEven | bool | false | Move stop to breakeven after profit reaches BreakEvenATR * ATR (caution: creates friction drag on mean reversion) |
BreakEvenATR | float64 | 1.5 | ATR multiple of profit required to arm break-even stop |
UseProfitTarget | bool | true | Exit at a fixed profit target of ProfitTargetATR * ATR |
ProfitTargetATR | float64 | 1.5 | ATR multiple for profit target |
UseLimitEntry | bool | true | Use limit orders instead of market orders for entry |
LimitOffsetATR | float64 | 0.5 | ATR offset from close for limit entry price |
UseDollarTrailing | bool | false | Trail stop from peak profit by TrailingATR * ATR |
TrailingATR | float64 | 1.5 | ATR multiple for dollar trailing stop distance |
UseStopTightening | bool | false | Enable progressive stop tightening after N bars |
StopTightenAfter | int | 3 | Tighten stop after this many bars in a trade |
TightenedStopATR | float64 | 1.5 | ATR multiple for tightened stop (replaces ATRStopMultiplier after StopTightenAfter bars) |
whiplash Inputs
Based on the paper “Filtered Market Statistics and Technical Trading Rules” by Z. George Yang (SSRN 2260609, 2013). The strategy filters out “nearly flat” days using a VIX-derived threshold, then counts consecutive “essential” up or down days. After RunsLength consecutive essential down days the strategy goes long (mean reversion); after RunsLength consecutive essential up days it goes short.
The strategy automatically loads VIX index data ($VIXCLS from FRED) as a secondary series and requires the primary symbol to use daily bars.
| Input | Type | Default | Description |
|---|
RunsLength | int | 2 | Number of consecutive essential days in the same direction required to trigger a position switch |
VixFilterPct | float64 | 0.22 | Filter threshold as a fraction of daily implied volatility from VIX. Threshold d = VixFilterPct × VIX / (100 × √252) |
MaxHoldBars | int | 7 | Exit all positions after this many bars since the most recent entry. Mean reversion edge decays rapidly; trades held beyond ~10 bars have a >70% loss rate. Set to 0 to disable |
VixCeiling | float64 | 0 | Suppress new entries when VIX exceeds this level. Disabled by default (0). Caution: also blocks profitable recovery bounces during high-VIX regimes |
WaitBarsAfterLoser | int | 5 | Suppress new entries for N bars after a losing trade closes. Prevents repeated entries into a sustained selloff. Set to 0 to disable |
TrendSMALength | int | 0 | SMA period for trend filter (long only when close > SMA, short only when close < SMA). Disabled by default; testing shows it hurts mean reversion strategies |
NoPyramidWhenLosing | bool | false | Suppress pyramiding when the open position is underwater. Disabled by default |
VixSpikeLookback | int | 0 | Bars over which to measure VIX rate of change. Suppresses entries during rapid VIX spikes. Set to 0 to disable |
VixSpikeThreshold | float64 | 0.60 | Block entries when VIX has risen by more than this fraction (0.60 = 60%) over VixSpikeLookback bars |
ATRStopMultiplier | float64 | 0 | ATR-based stop loss multiplier. Set to 0 to disable. Caution: tight stops hurt mean reversion trades which naturally have large adverse excursion before recovering |
ATRStopLength | int | 20 | ATR lookback period for stop loss calculation |
blackbird Inputs
A long convexity tail-risk hedging strategy designed to run alongside mean-reversion strategies like whiplash. It manufactures an options-like payoff from linear futures: frequent small losses (the “insurance premium”) punctuated by large gains during sudden market crashes.
The strategy requires two conditions to enter short: (1) VIX must have accelerated recently (risen by VixROCThreshold over VixROCLen bars), and (2) confirming signals must fire — by default BOTH a Donchian channel breakdown AND a momentum collapse (price ROC exceeding MomoThreshold standard deviations below its mean) must trigger simultaneously. This dual-confirmation approach dramatically reduces false signals.
All exits use close prices only (no intrabar stops). During crash-period volatility, intraday swings are extreme and would trigger conventional stops even on directionally correct trades. Instead, the strategy uses a close-price adverse-move stop, a time-based stop for unprofitable trades, and an ATR-based trailing stop that activates once the trade is significantly profitable.
The strategy automatically loads VIX index data ($VIXCLS from FRED) as a secondary series and requires the primary symbol to use daily bars.
| Input | Type | Default | Description |
|---|
VixROCLen | int | 3 | Lookback in bars for measuring VIX rate of change |
VixROCThreshold | float64 | 0.30 | Fractional VIX rise required (0.30 = 30% over VixROCLen bars) |
VixAccelMemory | int | 3 | Bars that a VIX acceleration signal remains valid for confirmation |
DonchianLen | int | 20 | Donchian low channel lookback for the price breakdown trigger |
MomoROCLen | int | 5 | Price rate-of-change lookback for momentum collapse trigger |
MomoStdDevLen | int | 60 | Lookback for ROC mean/stddev used to compute the z-score |
MomoThreshold | float64 | 3.5 | Z-score threshold: entry when price ROC is this many standard deviations below mean |
ATRLen | int | 14 | ATR lookback period |
StopATRMult | float64 | 2.0 | Close-price stop distance in ATR multiples. Evaluated on close only (not intrabar) |
TimeStopBars | int | 1 | Exit after this many bars if trade is not profitable |
TrailActivateATR | float64 | 3.0 | Profit in ATR multiples required to activate the trailing stop |
TrailATRMult | float64 | 3.0 | Trailing stop width in ATR multiples above the lowest close since entry |
MaxHoldBars | int | 15 | Maximum bars to hold any position |
CooldownBars | int | 12 | Minimum bars between entries |
VixMinForEntry | float64 | 22 | Suppress entries when VIX is below this level |
MaxPriorDropPct | float64 | 0.07 | Suppress entry when price has already dropped more than this percentage over the last MaxPriorDropBars bars. Avoids entering short after a fast crash has already played out and a bounce is imminent |
RequireBothConfirmations | bool | true | When true, requires BOTH Donchian breakdown AND momentum collapse. When false, either one suffices |
MaxPriorDropBars | int | 10 | Lookback period for the prior-drop filter |
slowcrash Inputs
A long convexity strategy that complements blackbird by targeting grinding, multi-week selloffs rather than sharp 1-3 day crashes. The key insight: by the time lagging indicators confirm a grinding selloff, it’s often near its bottom. Instead, this strategy enters early when persistent fear first appears, accepts a fixed insurance premium if wrong, and rides the trend if the selloff develops.
Entry requires five simultaneous conditions:
- Persistent VIX elevation — VIX must have been above
VixThreshold for at least VixPersistBars consecutive bars, signalling structural fear rather than a transient spike. - VIX still rising — VIX must be higher than it was
VixRisingLen bars ago, filtering out post-crisis periods where VIX is elevated but declining (normalizing). - Price below SMA — Close must be below its
PriceSMALen-bar simple moving average, confirming the market is in a downtrend. - Trend still active — Close must be lower than it was
SlopeLen bars ago, confirming the trend hasn’t stalled or reversed. - Not bouncing — Close must not have risen more than
BounceMaxPct from its recent low, preventing entry after a V-bounce when VIX is still residually elevated.
All exits use close prices only (no intrabar stops). The strategy uses a wide ATR-based stop (the “insurance premium”), a trailing stop that activates after significant profit, and a maximum hold period. Unlike blackbird, there is no time stop — grinding selloffs produce daily bounces that would trigger time-based exits prematurely.
The strategy automatically loads VIX index data ($VIXCLS from FRED) as a secondary series and requires the primary symbol to use daily bars.
| Input | Type | Default | Description |
|---|
VixThreshold | float64 | 25 | VIX level that must be sustained for entry |
VixPersistBars | int | 7 | Consecutive bars VIX must remain above VixThreshold |
VixRisingLen | int | 15 | Lookback for VIX rising check. VIX must be higher than this many bars ago. Set to 0 to disable |
PriceSMALen | int | 40 | SMA period. Close must be below this SMA |
SlopeLen | int | 10 | Trend direction lookback. Close must be lower than SlopeLen bars ago |
BounceMaxPct | float64 | 0.05 | Maximum bounce from recent low (5% = 0.05). Set to 0 to disable |
ATRLen | int | 14 | ATR lookback period |
StopATRMult | float64 | 3.0 | Close-price stop distance in ATR multiples (the insurance premium) |
TrailActivateATR | float64 | 3.5 | Profit in ATR multiples required to activate trailing stop |
TrailATRMult | float64 | 2.0 | Trailing stop width in ATR multiples above lowest close since entry |
MaxHoldBars | int | 30 | Maximum bars to hold any position |
CooldownBars | int | 60 | Minimum bars between entries. Long cooldown prevents repeated losses during the same volatile period |
Turtle Trading
| Strategy | Description |
|---|
turtle-original-1 | Original Turtle System 1 |
turtle-original-2 | Original Turtle System 2 |
turtle-kmg | Modified Turtle system |
Multi-Timeframe
| Strategy | Description |
|---|
mrft | Multi-resolution framework trading |
lookaway | Multi-timeframe analysis |
weekly | Weekly timeframe strategy |
mrft Inputs
| Input | Type | Default | Description |
|---|
ExitPriceLookBackBars | int | 1 | Lookback bars for exit price reference |
IsDynamicSize | bool | true | Enable risk-parity position sizing based on equity and point value (floor 1, ceiling 4 contracts) |
RiskPips | int | 25 | Risk per trade in basis points (25 = 0.25%); only used when IsDynamicSize is true |
WaitBarsAfterLoser | int | 0 | 0–20 |
Utility and Analysis
| Strategy | Description |
|---|
buyhold | Buy and hold baseline |
bars | Bar analysis |
randomise | Random signal generator (for baseline comparison) |
edgefinder | Edge detection |
contindex | Continuous contract index |
Regime and Volatility
| Strategy | Description |
|---|
regime | Regime filter |
regimefilter | Additional regime filtering |
volatility | Volatility-based strategy |
Use algo strategies -i <name> to see the inputs for any strategy.