- Flink update_bars debouncing - update_bars subscription idempotency bugfix - Price decimal correction bugfix of previous commit - Add GLM-5.1 model tag alongside renamed GLM-5 - Use short Anthropic model IDs (sonnet/haiku/opus) instead of full version strings - Allow @tags anywhere in message content, not just at start - Return hasOtherContent flag instead of trimmed rest string - Only trigger greeting stream when tag has no other content - Update workspace knowledge base references to platform/workspace and platform/shapes - Hierarchical knowledge base catalog - 151 Trading Strategies knowledge base articles - Shapes knowledge base article - MutateShapes tool instead of workspace patch
58 lines
3.0 KiB
Markdown
58 lines
3.0 KiB
Markdown
---
|
||
description: "Signals long/short entries when a shorter moving average crosses above or below a longer moving average, optionally augmented with stop-loss rules based on price thresholds."
|
||
tags: [stocks, trend-following, moving-average, technical-analysis]
|
||
---
|
||
|
||
# Two Moving Averages
|
||
|
||
**Section**: 3.12 | **Asset Class**: Stocks | **Type**: Trend-Following / Technical Analysis
|
||
|
||
## Overview
|
||
The two-moving-averages strategy replaces the current stock price in the single-MA signal with a shorter moving average. When the shorter MA crosses above the longer MA, a long position is established (bullish signal); when the shorter MA crosses below, a short position is established (bearish signal). This reduces sensitivity to single-day price noise relative to the single-MA strategy.
|
||
|
||
## Construction / Signal
|
||
Two MAs with lengths T' < T (e.g., T' = 10 days, T = 30 days):
|
||
|
||
**Basic signal**:
|
||
```
|
||
Signal = { Establish long / liquidate short if MA(T') > MA(T)
|
||
{ Establish short / liquidate long if MA(T') < MA(T) (322)
|
||
```
|
||
|
||
**With stop-loss rules** (Delta is a predefined percentage threshold, e.g., Delta = 2%):
|
||
|
||
Let P_1 be the previous day's closing price:
|
||
```
|
||
Signal = { Establish long position if MA(T') > MA(T)
|
||
{ Liquidate long position if P < (1 - Delta) * P_1
|
||
{ Establish short position if MA(T') < MA(T)
|
||
{ Liquidate short position if P > (1 + Delta) * P_1 (323)
|
||
```
|
||
|
||
A long position is liquidated if the current price P falls more than Delta below the previous day's price P_1 (even if the shorter MA has not yet crossed the longer MA). Similarly, a short position is liquidated if P rises more than Delta above P_1.
|
||
|
||
## Entry / Exit Rules
|
||
- **Long entry**: MA(T') crosses above MA(T).
|
||
- **Long exit**: MA(T') crosses below MA(T), or price falls Delta% below prior day's close (stop-loss).
|
||
- **Short entry**: MA(T') crosses below MA(T).
|
||
- **Short exit**: MA(T') crosses above MA(T), or price rises Delta% above prior day's close (stop-loss).
|
||
|
||
## Key Parameters
|
||
- **Short MA length T'**: Typically 10–50 trading days
|
||
- **Long MA length T**: Typically 30–200 trading days; T' < T required
|
||
- **MA type**: SMA or EMA for both
|
||
- **Stop-loss threshold Delta**: Typically 1–3% (e.g., 2%)
|
||
- **Example**: T' = 10, T = 30; or classic "golden cross" T' = 50, T = 200
|
||
|
||
## Variations
|
||
- **No stop-loss**: Use basic signal (Eq. 322) only
|
||
- **EMA crossover**: Use exponential MAs instead of simple MAs for both T' and T
|
||
- **Three moving averages**: See Section 3.13 for additional false-signal filtering
|
||
|
||
## Notes
|
||
- The two-MA crossover is a classic technical analysis signal (e.g., "golden cross": 50-day MA crosses 200-day MA bullishly).
|
||
- Stop-loss rules protect realized profits but can trigger premature exits if the shorter MA has not yet crossed.
|
||
- Like all single-stock technical analysis strategies, this is considered "unscientific" by many academics but is widely used in practice.
|
||
- Applicable on a single-stock or multi-stock basis.
|
||
- Delta must be calibrated via backtesting; too tight a stop causes excessive whipsaw, too loose provides little protection.
|