Write unambiguous trading rules: entry, exit, and position sizing. This IS Section 3a of your IP.
A signal is not a hypothesis — it's the operational rule that generates buy/sell decisions. This week teaches three major signal types (z-score, momentum, regression), how to specify entry and exit rules without whipsawing, and how to size positions based on volatility and edge strength.
Z-score measures deviation from the rolling mean in standard deviations.
\[ z_t = \frac{x_t - \mu_{t,w}}{\sigma_{t,w}} \]Where x_t is price or returns, w is lookback window, μ and σ are rolling mean and std.
Entry rule: Long when z < -2.0 (price is 2 std below average). Short when z > +2.0.
Exit rule: Exit when z crosses zero (price returns to mean). Or time-based: exit after 20 trading days if signal hasn't closed.
Typical use: Pairs trading, commodity mean reversion, currency mean reversion.
Advantage: Simple, easy to interpret. Disadvantage: whipsaws in trending markets.
Momentum measures the rate of change in price. EWMAC (Exponentially Weighted Moving Average Convergence Divergence) is the most robust version.
\[ \text{EWMAC}_{f,s} = \text{EWM}_{t,f} - \text{EWM}_{t,s} \]Where EWM_f is fast (short lookback), EWM_s is slow (long lookback).
Entry rule: Long when EWMAC > 0 and positive regime filter. Short when EWMAC < 0.
Exit rule: Exit when EWMAC crosses zero. Or time-based: exit after 60 days.
Parameters: Fast window (e.g., 8 days), slow window (e.g., 32 days). Use powers of 2 for efficiency.
Typical use: Trend-following in commodities, equities, FX.
Advantage: Captures trends, avoids mean-reversion whipsaws. Disadvantage: lags trend reversals.
Fit a regression model to predict forward returns. Use the fitted value as the signal.
\[ \hat{r}_{t+h} = \alpha + \beta_1 x_{1,t} + \beta_2 x_{2,t} + \varepsilon \]Where x_i are predictors (fundamental data, alternative data, technical factors).
Signal: Predicted return \(\hat{r}_{t+h}\). Positive = long, negative = short.
Entry rule: Long when \(\hat{r} > \text{threshold}\) (e.g., 0.5% expected return).
Exit rule: Exit when \(\hat{r} < 0\) (expected return turns negative) or after 20 days.
Advantage: Can use multiple factors. Captures fundamental information.
Disadvantage: More parameters, higher overfitting risk. Must test assumptions carefully (Section 3b).
Scale position size inversely to volatility. High volatility → smaller position. Low volatility → larger position. Maintains constant risk contribution.
\[ \text{position size} = \frac{\text{target vol}}{\sigma_t} \cdot \text{capital} \]Example:
target_vol = 0.10 # 10% annualized target volatility
annual_factor = np.sqrt(252)
realized_vol = returns.rolling(20).std() * annual_factor
position_size = (target_vol / realized_vol) * capital
# When realized_vol is high (20%), size down
# When realized_vol is low (5%), size up
Advantage: Risk contribution is stable across time. Avoids overlevering in calm periods.
Optimal fraction of capital to bet given win probability and payoff ratio.
\[ f^* = \frac{p \cdot b - q}{b} \]Where p = win probability, q = 1-p, b = win/loss ratio.
Full Kelly is too aggressive. Most funds use half-Kelly or quarter-Kelly.
A regime filter conditions signal execution on market state. Example: only trade momentum when in an uptrend.
Example: Trend filter
\[ \text{regime}_t = \mathbb{1}\left[P_t > \text{EMA}_{t,200}\right] \]Only execute momentum signals when price is above the 200-day exponential moving average. In downtrends, stay in cash.
Advantage: Reduces drawdowns by avoiding trades in bad regimes. Disadvantage: Misses opportunities at regime transitions.
Price (blue), z-score signal (orange), entry points (green dots = buy, red = sell). Notice the whipsaws: several short-lived entries and exits. This is mean reversion, not ideal in trends.
SECTION 3A: SIGNAL CONSTRUCTION
3a.1 Signal formula
z_t = (close_t - mean(close_t-20:t)) / std(close_t-20:t)
3a.2 Entry rule
Long: z_t < -1.5 AND regime_t = 1 (positive trend)
regime_t = 1 if close_t > EMA(close, 50), else 0
3a.3 Exit rule
Exit long if: z_t > 0 OR position held for 30 days, whichever first
3a.4 Position sizing
units = (target_vol / realized_vol) * capital / price
target_vol = 0.10 (10% annual target)
realized_vol = 20-day rolling volatility, annualized