Indicator · Pine Script v5 · Own pane

Mojito v3 Strategy

by namuan

The Mojito v3 Strategy indicator evaluates volatility term structure by calculating the ratio between front-month and second-month VIX futures contracts.

View on GitHub

GitHub stars318on the repository
Pine versionv5runs as is
Lines of code44
Settings3inputs
LicenceMIT
Last update2 months ago18 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

44 lines of Pine Script v5 from tv-scripts/tvt-mojito-vix-45.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

tvt-mojito-vix-45.pine
//@version=5
indicator("Mojito v3 Strategy", overlay=false)

// Color Constants
const color LONG_REGIME_COLOR = color.new(color.green, 70)
const color SHORT_REGIME_COLOR = color.new(color.red, 70)
const color NEUTRAL_REGIME_COLOR = color.new(color.gray, 85)
const color IVTS_COLOR = color.blue

// Futures Contract Symbols
shortTermFutures = request.security("VX1!", timeframe.period, close)
midTermFutures = request.security("VX2!", timeframe.period, close)

// IVTS Calculation with Validation
ivts = na(shortTermFutures) or na(midTermFutures) ? na : shortTermFutures / midTermFutures

// Median Filter with Configurable Length
median_length = input.int(5, minval=1, title="Median Filter Length")
median_ivts = ta.median(ivts, median_length)

// Trading Conditions with Configurable Thresholds
longThreshold = input.float(1.10, minval=1.0, title="Long Threshold")
shortThreshold = input.float(0.91, maxval=1.0, title="Short Threshold")

longCondition = median_ivts > longThreshold
shortCondition = median_ivts < shortThreshold
neutralCondition = median_ivts >= shortThreshold and median_ivts <= longThreshold

// Plot Median IVTS
plot(median_ivts, "Median IVTS", color=IVTS_COLOR, linewidth=2)

// Dynamic Background Coloring
bgcolor(longCondition ? LONG_REGIME_COLOR : shortCondition ? SHORT_REGIME_COLOR : NEUTRAL_REGIME_COLOR)

// Threshold Level Lines
hline(longThreshold, "Long Threshold", color=color.new(color.green, 0), linestyle=hline.style_dashed)
hline(shortThreshold, "Short Threshold", color=color.new(color.red, 0), linestyle=hline.style_dashed)

// Informative Table with Improved Formatting
var table infoTable = table.new(position.top_right, 1, 4)  // Increased to 4 rows
table.cell(infoTable, 0, 0, "IVTS: " + str.tostring(median_ivts, "#.##"))
table.cell(infoTable, 0, 1, longCondition ? "Regime: Long" : shortCondition ? "Regime: Short" : "Regime: Neutral")
table.cell(infoTable, 0, 2, "Position:")
table.cell(infoTable, 0, 3, longCondition ? "60% long VXX" : shortCondition ? "60% short VXX" : "No Position")

Overview

Mojito v3 Strategy smooths this ratio using a configurable median filter and compares the result against user-defined upper and lower thresholds. Crossing above the upper threshold signals a long volatility regime, while dropping below the lower threshold signals a short volatility regime. It plots the median ratio in a separate pane with threshold lines, tints the background by regime, and displays a status table with suggested VXX position allocations.

Details

Published by

namuan on GitHub

Type

Indicator, Pine Script v5

Draws

Separate pane below the chart

Category

Volatility & bands

Markets

Indices

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

trading-strategiesmarket-analysisdtalestock-market-analysistelegram-botearnings-calendaroptions-trading

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Median Filter Lengthint5median_length
Long Thresholdfloat1.10longThreshold
Short Thresholdfloat0.91shortThreshold
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

This indicator calculates the distribution of close-to-close percentage changes using rate of change on closing prices. It bins percentage changes into intervals of 0.25 percent increments from negative to positive values and plots a normalized cumulative hist

Indicator v4 Volatility & bands
Updated 10 days ago · GPL-3.0 GitHub repository of Close-to-Close % Change Distribution

This indicator plots a Supertrend-based trend-following setup in a separate pane and skips conditions it treats as a sideways market. A volatility range is built from an ATR value, with RMA, SMA, EMA, or WMA smoothing, or from a fixed point distance. Optional

Indicator v5 TrendVolatility & bands
Updated 1 year ago · MPL-2.0 GitHub repository of Trend Following Setup - Sideways Market Skipper
330 stars

This indicator plots candle range and open-to-close movement as percentages in a separate pane. Range is the high-low difference divided by the low, and change is the close-open difference divided by the open. Both series draw as columns. Teal columns show ran

Indicator v5 Volatility & bands
Updated 2 months ago · None stated GitHub repository of Percent & Volatility [Alorse]

Function - Logistic Equation

by ricardosantos79
261 stars

Calculates dynamic modeling values by applying a mathematical logistic differential equation to price change over a specified lookback length. It measures price momentum relative to the recent high-low price range. The script plots positive and negative logist

Indicator v5 Oscillators & momentumVolatility & bands
Updated 4 years ago · None stated GitHub repository of Function - Logistic Equation

MACD-V

by harryguiacorn
219 stars

MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us

Indicator v5 Oscillators & momentumVolatility & bands
Updated 1 year ago · None stated GitHub repository of MACD-V
218 stars

This indicator detects a Bollinger Band squeeze when the bands sit inside Keltner Channels, marking low volatility. It plots red dots during a squeeze and green dots when the bands are outside, in a separate pane. An optional histogram shows momentum as the cl

Indicator v6 Volatility & bandsOscillators & momentum
Updated 3 months ago · None stated GitHub repository of Bollinger Band Squeeze Detector

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers