liveBook · Manning

Momentum

As explained in Investing for Programmers

Momentum investing is an investment approach that seeks to profit from continuing trends in asset prices.

Momentum investing seeks to profit from continuing price trends. When an asset keeps rising, momentum investors may hold or continue buying rather than expect an immediate reversal. The approach contrasts with mean reversion and contrarian investing, and momentum eventually weakens rather than lasting indefinitely. section 10.1.1

Chart-based momentum analysis connects price action with time horizon and technical indicators:

  • Candlesticks provide quick visual clues: large bodies indicate strong momentum, while long wicks can show rejection or support. section 10.2.1
  • Moving-average crossovers, such as the 5-day and 200-day SMAs, are among the algorithmic signals used by technical traders. section 10.1.3
  • The Ichimoku Cloud combines trend, momentum, support, and resistance; price above the cloud indicates an uptrend, while price inside suggests consolidation. section 10.2.3
  • Short-term leveraged trading requires earlier decisions because borrowed funds accrue interest, while long-term investors may tolerate temporary declines within an upward trend. section 10.1.3

NVIDIA chart analysis

A Python workflow can download NVIDIA prices, calculate Ichimoku lines over nine-, 26-, and 52-day windows, and plot the resulting cloud. Green clouds represent bullish momentum; red clouds represent bearish momentum. section 10.2.3

Listing 10.6 Creating an Ichimoku
import yfinance as yf
import matplotlib.pyplot as plt
ticker = "NVDA"
data = yf.Ticker(ticker).history(start="2024-01-10", end="2025-01-15")
df = pd.DataFrame(data).dropna()
df.reset_index(inplace=True)

df["ConversationLine"] = (df["Close"].rolling(
  window=9).max() + df["Close"].rolling(
  window=9).min()) / 2                                   #1
df["BaseLine"] = (df["Close"].rolling(
  window=26).max() + df["Close"].rolling(
  window=26).min()) / 2                               #1  
df["SpanA"] = ((df["ConversationLine"] 
                + df["BaseLine"]) / 2).shift(26)      #1  
df["SpanB"] = ((df["Close"].rolling(
               window=52).max() + df["Close"].rolling(
               window=52).min()) / 2).shift(26)       #1  
df["LaggingSpan"] = df["Close"].shift(-26)            #1  

plt.figure(figsize=(12, 6))
plt.plot(df.index, df["Close"], label="Close Price", color="black")
plt.plot(df.index, df["ConversationLine"], label="ConversationLine", 
color="red")
plt.plot(df.index, df["BaseLine"], label="BaseLine", color="blue")
plt.fill_between(df.index, df["SpanA"], df["SpanB"], 
  where=df["SpanA"] >= df["SpanA"], color="lightgreen", alpha=0.5)
plt.fill_between(df.index, df["SpanA"], df["SpanB"], 
  where=df["SpanA"] < df["SpanB"], color="lightcoral", alpha=0.5)
plt.plot(df.index, df["LaggingSpan"], label="LaggingSpan", color="purple", linestyle="dotted")

plt.title("Ichimoku Cloud")
plt.legend()
plt.show()

Inspect the executable Ichimoku construction, including rolling price windows, shifted spans, and the plotted closing-price series. section 10.2.3

How Investing for Programmers covers it

How deep it goes
Connects momentum to candlesticks, moving averages, and Ichimoku components, but does not establish technical analysis effectiveness.
Examples
Uses NVIDIA, candlestick patterns, SMA crossovers, wildfire-related trades, and an Ichimoku chart as concrete illustrations.
What you can do after
Apply it via Python charting workflows that visualize candlesticks, moving averages, or Ichimoku momentum signals.
How it connects
Ties momentum to mean reversion, contrarian investing, technical analysis, moving averages, candlesticks, and Ichimoku Cloud.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Investing for Programmers. The section links point to the parts of the book it draws on.