Strategy · Pine Script v5 · Own pane

TSI Strategy - Eterna MCP

by EternaHybridExchange

The TSI Strategy - Eterna MCP calculates the True Strength Index using double-smoothed momentum and an exponential moving average signal line.

View on GitHub

GitHub stars9on the repository
Pine versionv5runs as is
Lines of code96
Settings7inputs
LicenceMIT
Last update7 months ago12 Mar 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 strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

96 lines of Pine Script v5 from strategies/momentum/tsi_strategy.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

tsi_strategy.pine
//@version=5
strategy("TSI Strategy - Eterna MCP", 
         shorttitle="TSI",
         overlay=false,
         default_qty_type=strategy.percent_of_equity,
         default_qty_value=100,
         initial_capital=1000)

// ============================================
// PARAMETERS
// ============================================
longLength = input.int(25, "Long Length", minval=1)
shortLength = input.int(13, "Short Length", minval=1)
signalLength = input.int(13, "Signal Length", minval=1)
overboughtLevel = input.int(25, "Overbought", minval=10, maxval=50)
oversoldLevel = input.int(-25, "Oversold", minval=-50, maxval=-10)
leverageSize = input.float(5.0, "Leverage", minval=1, maxval=100)
positionSize = input.float(0.01, "Position Size", minval=0.001, maxval=1)

// ============================================
// TSI CALCULATION
// ============================================
// Price change
pc = ta.change(close)

// Double smoothed momentum
double_smoothed_pc = ta.ema(ta.ema(pc, longLength), shortLength)
double_smoothed_abs_pc = ta.ema(ta.ema(math.abs(pc), longLength), shortLength)

// TSI
tsi = 100 * (double_smoothed_pc / double_smoothed_abs_pc)

// Signal line
signal = ta.ema(tsi, signalLength)

// ============================================
// SIGNAL GENERATION
// ============================================
// Crossover signals
bullishCross = ta.crossover(tsi, signal)
bearishCross = ta.crossunder(tsi, signal)

// Zero-line cross (trend change)
bullishZero = ta.crossover(tsi, 0)
bearishZero = ta.crossunder(tsi, 0)

// Oversold/Overbought with momentum
bullishOB = tsi < oversoldLevel and tsi > tsi[1] and bullishCross
bearishOS = tsi > overboughtLevel and tsi < tsi[1] and bearishCross

// Combined entry signals
buySignal = (bullishCross and tsi < 0) or bullishOB
sellSignal = (bearishCross and tsi > 0) or bearishOS

// ============================================
// STRATEGY LOGIC
// ============================================
if buySignal and strategy.position_size == 0
    strategy.entry("Long", strategy.long)
    alert('{"action":"buy","symbol":"' + syminfo.ticker + '","size":' + str.tostring(positionSize) + ',"leverage":' + str.tostring(leverageSize) + '}', alert.freq_once_per_bar_close)

if sellSignal and strategy.position_size == 0
    strategy.entry("Short", strategy.short)
    alert('{"action":"sell","symbol":"' + syminfo.ticker + '","size":' + str.tostring(positionSize) + ',"leverage":' + str.tostring(leverageSize) + '}', alert.freq_once_per_bar_close)

// Exit on opposite signal
if sellSignal and strategy.position_size > 0
    strategy.close("Long")

if buySignal and strategy.position_size < 0
    strategy.close("Short")

// ============================================
// PLOTTING
// ============================================
plot(tsi, "TSI", color=color.blue, linewidth=2)
plot(signal, "Signal", color=color.orange, linewidth=1)
hline(overboughtLevel, "Overbought", color=color.red, linestyle=hline.style_dashed)
hline(oversoldLevel, "Oversold", color=color.green, linestyle=hline.style_dashed)
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_solid, linewidth=2)

// Histogram
histogram = tsi - signal
plot(histogram, "Histogram", color=histogram > 0 ? color.green : color.red, style=plot.style_histogram, linewidth=2)

// Signals
plotshape(buySignal, "Buy", shape.triangleup, location.bottom, color.green, size=size.normal)
plotshape(sellSignal, "Sell", shape.triangledown, location.top, color.red, size=size.normal)

// Trend markers
plotshape(bullishZero, "Bull Trend", shape.circle, location.bottom, color.lime, size=size.tiny)
plotshape(bearishZero, "Bear Trend", shape.circle, location.top, color.orange, size=size.tiny)

// Background coloring
bgcolor(tsi > overboughtLevel ? color.new(color.red, 95) : 
        tsi < oversoldLevel ? color.new(color.green, 95) : na)

Overview

TSI Strategy - Eterna MCP opens long positions on bullish signal line crossovers occurring below zero or in oversold territory, and short positions on bearish crossovers above zero or in overbought territory. Open trades are closed when an opposing entry signal triggers. The strategy emits JSON webhook alerts configured for automated execution and plots the oscillator, signal line, histogram, and threshold levels in a separate pane. It contains no built-in stop-loss mechanism.

Details

Published by

EternaHybridExchange on GitHub

Type

Strategy, Pine Script v5

Draws

Separate pane below the chart

Category

Oscillators & momentum

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingautomated-tradingbacktestingbybitcrypto-tradingeternamcppine-scripttrading-strategiestradingview

Settings

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

SettingTypeDefaultVariable
Long Lengthint25longLength
Short Lengthint13shortLength
Signal Lengthint13signalLength
Overboughtint25overboughtLevel
Oversoldint-25oversoldLevel
Leveragefloat5.0leverageSize
Position Sizefloat0.01positionSize
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

330 stars

MACD + Divergences [Alorse] is a momentum strategy that calculates the MACD oscillator and identifies regular and hidden divergences using pivot high and low points. It filters trade signals with dual Exponential Moving Averages (EMA 150 and 600) to ensure tra

Strategy v4 Oscillators & momentumDivergence Repaints
Updated 2 months ago · None stated GitHub repository of MACD + Divergences [Alorse]

Q-Trend + KVO Strategy

by TradersPost
218 stars

This strategy combines the ATR-banded Q-Trend indicator with the Klinger Volume Oscillator (KVO) to execute confluence trades. It enters long when a Q-Trend buy trigger aligns with a positive KVO value and a bullish candle confirmation, taking short trades und

Strategy v6 TrendVolume
Updated 3 months ago · None stated GitHub repository of Q-Trend + KVO Strategy

MACD Crossover (tutorial)

by pineforge-4pass
193 stars

This strategy calculates the Moving Average Convergence Divergence indicator and plots the MACD line, signal line, and histogram in a separate pane. It enters long positions when the MACD line crosses above the signal line and enters short positions when it cr

Strategy v6 Oscillators & momentumMoving averages
Updated today · Apache-2.0 GitHub repository of MACD Crossover (tutorial)
114 stars

This strategy estimates price behavior using ordinary least squares regression between higher-timeframe data and a generated dataset, smoothed by a Karobein oscillator. It enters long positions when the oscillator turns upward and short positions when it turns

Strategy v4 Oscillators & momentumAI / machine learning Repaints

2xTP, SL to Entry

by hasnocool
106 stars

This strategy executes mean-reversion trades based on Bollinger Bands and the Stochastic Oscillator. Long orders trigger when price dips below the lower band alongside a bullish Stochastic crossover, with an optional oversold threshold. Short orders execute on

Strategy v5 Mean reversionOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 2xTP, SL to Entry
65 stars

This strategy calculates a 20-period Relative Strength Index (RSI) and generates entry orders based on crossovers and crossunders of the 50 level. When RSI crosses above 50, it places a long stop entry at the current high price with a custom alert message. Whe

Strategy v4 Oscillators & momentum
Updated 4 days ago · GPL-3.0 GitHub repository of Strategy Using Alert Message

More strategys

Trade Your Charts With a Regulated Broker

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

Compare brokers