initial commit

This commit is contained in:
mfcheah
2026-04-09 14:16:26 +08:00
commit bd681dc939
4 changed files with 118 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
# John Carter TTM TradingView Project
This repository contains Pine Script implementations of John Carters **TTM Trend** and **TTM Squeeze** indicators, adapted for TradingView.
It also includes crossover logic (8/18 SMA) and long-term trend filters (100 SMA).
---
## 📂 Project Structure
- `ttm_trend.pine` → Solid candle coloring (blue/red/gray) + SMA crossover signals.
- `ttm_squeeze.pine` → Momentum histogram + squeeze dots (with adjustable size).
- `ttm_strategy.pine` → Combined signals for backtesting entries/exits.
- `README.md` → Documentation and usage notes.
---
## ⚙️ Default Settings (John Carter)
- **TTM Squeeze**
- Bollinger Bands: 20-period SMA, 2.0 StdDev
- Keltner Channels: 20-period SMA, 1.5 × ATR
- Histogram: 20-period linear regression
- **TTM Trend**
- Trend baseline: 20 SMA
- Candle colors: Blue (uptrend), Red (downtrend), Gray (neutral)
- **Crossover**
- Fast SMA: 8
- Slow SMA: 18
- Long-term SMA: 100 (white)
---
## 🚀 Usage
1. Copy `.pine` files into TradingViews Pine Editor.
2. Add indicators to your chart:
- Overlay `ttm_trend.pine` on price.
- Add `ttm_squeeze.pine` in a separate panel.
3. Adjust inputs (lengths, multipliers) in the settings panel to match your trading style.
---
## 📈 Strategy Notes
- **Buy Signal**: 8 SMA crosses above 18 SMA, candles blue, squeeze fires.
- **Sell Signal**: 8 SMA crosses below 18 SMA, candles red, squeeze fires.
- **Filter**: Optional — only take signals aligned with the 100 SMA trend.
---
## 📝 Next Steps
- Add alerts for squeeze releases.
- Backtest combined signals in `ttm_strategy.pine`.
- Experiment with different lengths (e.g., 21, 30) for volatility adaptation.
+29
View File
@@ -0,0 +1,29 @@
//@version=5
indicator("TTM Squeeze", overlay=false)
squeezeLen = input.int(20, "Squeeze Length")
mult = input.float(2.0, "StdDev Multiplier")
// Bollinger Bands
basis = ta.sma(close, squeezeLen)
dev = mult * ta.stdev(close, squeezeLen)
upperBB = basis + dev
lowerBB = basis - dev
// Keltner Channels
atr = ta.atr(squeezeLen)
upperKC = basis + atr * 1.5
lowerKC = basis - atr * 1.5
// Squeeze condition
squeezeOn = (upperBB < upperKC) and (lowerBB > lowerKC)
// Momentum histogram
mom = ta.linreg(close - basis, squeezeLen, 0)
// Bigger squeeze dots
plot(squeezeOn ? 0 : na, style=plot.style_circles, color=color.red, linewidth=4, title="Squeeze On")
plot(not squeezeOn ? 0 : na, style=plot.style_circles, color=color.green, linewidth=4, title="Squeeze Off")
// Momentum histogram
plot(mom, style=plot.style_histogram, color=mom >= 0 ? color.lime : color.orange, title="Momentum")
+39
View File
@@ -0,0 +1,39 @@
//@version=5
indicator("TTM Trend + SMA Crossover + 100 SMA", overlay=true)
// Trend baseline
length = input.int(20, "Trend Length")
ma = ta.sma(close, length)
// Candle colors (TTM Trend)
trendColor = close > ma ? color.blue : close < ma ? color.red : color.gray
plotcandle(open, high, low, close,
color=trendColor,
wickcolor=trendColor,
bordercolor=trendColor,
title="TTM Trend Candles")
// SMA crossover logic
fastLen = input.int(8, "Fast SMA")
slowLen = input.int(18, "Slow SMA")
fastMA = ta.sma(close, fastLen)
slowMA = ta.sma(close, slowLen)
plot(fastMA, color=color.yellow, title="8 SMA")
plot(slowMA, color=color.purple, title="18 SMA")
// Add 100 SMA in white
sma100 = ta.sma(close, 100)
plot(sma100, color=color.white, title="100 SMA")
// Detect crossovers
bullCross = ta.crossover(fastMA, slowMA)
bearCross = ta.crossunder(fastMA, slowMA)
// Print buy/sell labels
plotshape(bullCross, title="Buy Signal", text="BUY", style=shape.labelup,
location=location.belowbar, color=color.green, textcolor=color.white, size=size.tiny)
plotshape(bearCross, title="Sell Signal", text="SELL", style=shape.labeldown,
location=location.abovebar, color=color.red, textcolor=color.white, size=size.tiny)
View File