Indicator · Pine Script v6 · Own pane

Presidents Performance

by everget

This indicator measures the chart symbol’s percentage change from the opening price at the start of each US presidential term and plots those values as histogram columns in a separate pane.

View on GitHub

GitHub stars948on the repository
Pine versionv6current
Lines of code243
Settings2inputs
LicenceGPL-3.0
Last update10 days ago18 Oct 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

243 lines of Pine Script v6 from statistics/ticker_performance_by_us_president.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

ticker_performance_by_us_president.pine
//@version=6
// Copyright (c) 2020-present, Alex Orekhov (everget)
indicator('Presidents Performance')

width = input.int(title = 'Columns Width', minval = 1, defval = 15)
space = input.int(title = 'Space Between Columns', minval = 0, defval = 150)

var labelColor = #1e90ff
var labelTextColor = color.white
var labelStyle = shape.labelup
var labelLocation = location.absolute
var labelSize = size.small

t = time(timeframe.period)

_ts(y, m, d, h = 0, min = 0, s = 0) =>
    out = timestamp(y, m, d, h, min, s)
    out

_perf(presidency) =>
    var float start = na
    var float out = na
    start := na(start) and presidency ? open : start
    out := not na(start) and presidency ? 100 * (close - start) / start : out
    out

hline(0.0, title = 'Zero Level', linestyle = hline.style_dotted, color = #674ea7)

//------------------------------------------------------------------------------
// Donald Trump

trump2 = _perf(t > _ts(2025, 1, 20))
trump2Offset = 0

plot(trump2, offset = trump2Offset, title = 'Donald Trump', color = #f1625e, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(trump2, 0), offset = trump2Offset, title = 'Donald Trump', text = 'Trump', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Joe Biden

biden = _perf(_ts(2021, 1, 20) <= t and t <= _ts(2025, 1, 20))
bidenOffset = trump2Offset - space

plot(biden, offset = bidenOffset, title = 'Joe Biden', color = #9966cc, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(biden, 0), offset = bidenOffset, title = 'Joe Biden', text = 'Biden', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Donald Trump

trump = _perf(_ts(2017, 1, 20) <= t and t <= _ts(2021, 1, 20))
trumpOffset = bidenOffset - space

plot(trump, offset = trumpOffset, title = 'Donald Trump', color = #f1625e, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(trump, 0), offset = trumpOffset, title = 'Donald Trump', text = 'Trump', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Barack Obama

obama = _perf(_ts(2009, 1, 20) <= t and t <= _ts(2017, 1, 20))
obamaOffset = trumpOffset - space

plot(obama, offset = obamaOffset, title = 'Barack Obama', color = #9ace73, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(obama, 0), offset = obamaOffset, title = 'Barack Obama', text = 'Obama', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// George W. Bush

gw_bush = _perf(_ts(2001, 1, 20) <= t and t <= _ts(2009, 1, 20))
gw_bushOffset = obamaOffset - space

plot(gw_bush, offset = gw_bushOffset, title = 'George W. Bush', color = #ffdf82, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(gw_bush, 0), offset = gw_bushOffset, title = 'George W. Bush', text = 'G. Bush', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Bill Clinton

clinton = _perf(_ts(1993, 1, 20) <= t and t <= _ts(2001, 1, 20))
clintonOffset = gw_bushOffset - space

plot(clinton, offset = clintonOffset, title = 'Bill Clinton', color = #bb8954, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(clinton, 0), offset = clintonOffset, title = 'Bill Clinton', text = 'Clinton', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// George H. W. Bush

ghw_bush = _perf(_ts(1989, 1, 20) <= t and t <= _ts(1993, 1, 20))
ghw_bushOffset = clintonOffset - space

plot(ghw_bush, offset = ghw_bushOffset, title = 'George H. W. Bush', color = #4363d8, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(ghw_bush, 0), offset = ghw_bushOffset, title = 'George H. W. Bush', text = 'G. H. Bush', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Ronald Reagan

reagan = _perf(_ts(1981, 1, 20) <= t and t <= _ts(1989, 1, 20))
reaganOffset = ghw_bushOffset - space

plot(reagan, offset = reaganOffset, title = 'Ronald Reagan', color = #c46c54, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(reagan, 0), offset = reaganOffset, title = 'Ronald Reagan', text = 'Reagan', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Jimmy Carter

carter = _perf(_ts(1977, 1, 20) <= t and t <= _ts(1981, 1, 20))
carterOffset = reaganOffset - space

plot(carter, offset = carterOffset, title = 'Jimmy Carter', color = #5ec27c, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(carter, 0), offset = carterOffset, title = 'Jimmy Carter', text = 'Carter', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Gerald Ford

ford = _perf(_ts(1974, 8, 9) <= t and t <= _ts(1977, 1, 20))
fordOffset = carterOffset - space

plot(ford, offset = fordOffset, title = 'Gerald Ford', color = #e6194b, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(ford, 0), offset = fordOffset, title = 'Gerald Ford', text = 'Ford', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Richard Nixon

nixon = _perf(_ts(1969, 1, 20) <= t and t <= _ts(1974, 8, 9))
nixonOffset = fordOffset - space

plot(nixon, offset = nixonOffset, title = 'Richard Nixon', color = #3cb44b, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(nixon, 0), offset = nixonOffset, title = 'Richard Nixon', text = 'Nixon', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Lyndon B. Johnson

johnson = _perf(_ts(1963, 11, 22) <= t and t <= _ts(1969, 1, 20))
johnsonOffset = nixonOffset - space

plot(johnson, offset = johnsonOffset, title = 'Lyndon B. Johnson', color = #ffe119, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(johnson, 0), offset = johnsonOffset, title = 'Lyndon B. Johnson', text = 'Johnson', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// John F. Kennedy

kennedy = _perf(_ts(1961, 1, 20) <= t and t <= _ts(1963, 11, 22))
kennedyOffset = johnsonOffset - space

plot(kennedy, offset = kennedyOffset, title = 'John F. Kennedy', color = #f58231, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(kennedy, 0), offset = kennedyOffset, title = 'John F. Kennedy', text = 'Kennedy', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Dwight D. Eisenhower

eisenhower = _perf(_ts(1953, 1, 20) <= t and t <= _ts(1961, 1, 20))
eisenhowerOffset = kennedyOffset - space

plot(eisenhower, offset = eisenhowerOffset, title = 'Dwight D. Eisenhower', color = #008b8b, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(eisenhower, 0), offset = eisenhowerOffset, title = 'Dwight D. Eisenhower', text = 'Eisenhower', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Harry S. Truman

truman = _perf(_ts(1945, 4, 12) <= t and t <= _ts(1953, 1, 20))
trumanOffset = eisenhowerOffset - space

plot(truman, offset = trumanOffset, title = 'Harry S. Truman', color = #5059a5, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(truman, 0), offset = trumanOffset, title = 'Harry S. Truman', text = 'Truman', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Franklin D. Roosevelt

f_roosevelt = _perf(_ts(1933, 3, 4) <= t and t <= _ts(1945, 4, 12))
f_rooseveltOffset = trumanOffset - space

plot(f_roosevelt, offset = f_rooseveltOffset, title = 'Franklin D. Roosevelt', color = #b22222, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(f_roosevelt, 0), offset = f_rooseveltOffset, title = 'Franklin D. Roosevelt', text = 'F. Roosevelt', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Herbert Hoover

hoover = _perf(_ts(1929, 3, 4) <= t and t <= _ts(1933, 3, 4))
hooverOffset = f_rooseveltOffset - space

plot(hoover, offset = hooverOffset, title = 'Herbert Hoover', color = #ffd700, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(hoover, 0), offset = hooverOffset, title = 'Herbert Hoover', text = 'Hoover', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Calvin Coolidge

coolidge = _perf(_ts(1923, 8, 2) <= t and t <= _ts(1929, 3, 4))
coolidgeOffset = hooverOffset - space

plot(coolidge, offset = coolidgeOffset, title = 'Calvin Coolidge', color = #4b0082, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(coolidge, 0), offset = coolidgeOffset, title = 'Calvin Coolidge', text = 'Coolidge', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Warren G. Harding

harding = _perf(_ts(1921, 3, 4) <= t and t <= _ts(1923, 8, 2))
hardingOffset = coolidgeOffset - space

plot(harding, offset = hardingOffset, title = 'Warren G. Harding', color = #c71585, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(harding, 0), offset = hardingOffset, title = 'Warren G. Harding', text = 'Harding', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Woodrow Wilson

wilson = _perf(_ts(1913, 3, 4) <= t and t <= _ts(1921, 3, 4))
wilsonOffset = hardingOffset - space

plot(wilson, offset = wilsonOffset, title = 'Woodrow Wilson', color = #5f9ea0, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(wilson, 0), offset = wilsonOffset, title = 'Woodrow Wilson', text = 'Wilson', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// William Howard Taft

taft = _perf(_ts(1909, 3, 4) <= t and t <= _ts(1913, 3, 4))
taftOffset = wilsonOffset - space

plot(taft, offset = taftOffset, title = 'William Howard Taft', color = #b8860b, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(taft, 0), offset = taftOffset, title = 'William Howard Taft', text = 'Taft', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Theodore Roosevelt

t_roosevelt = _perf(_ts(1901, 9, 14) <= t and t <= _ts(1909, 3, 4))
t_rooseveltOffset = taftOffset - space

plot(t_roosevelt, offset = t_rooseveltOffset, title = 'Theodore Roosevelt', color = #7e5233, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(t_roosevelt, 0), offset = t_rooseveltOffset, title = 'Theodore Roosevelt', text = 'T. Roosevelt', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// William McKinley

mckinley = _perf(_ts(1897, 3, 4) <= t and t <= _ts(1901, 9, 14))
mckinleyOffset = t_rooseveltOffset - space

plot(mckinley, offset = mckinleyOffset, title = 'William McKinley', color = #3d986a, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(mckinley, 0), offset = mckinleyOffset, title = 'William McKinley', text = 'McKinley', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

//------------------------------------------------------------------------------
// Grover Cleveland

cleveland = _perf(_ts(1893, 3, 4) <= t and t <= _ts(1897, 3, 4))
clevelandOffset = mckinleyOffset - space

plot(cleveland, offset = clevelandOffset, title = 'Grover Cleveland', color = #f45b10, style = plot.style_histogram, linewidth = width, show_last = 1)
plotshape(math.min(cleveland, 0), offset = clevelandOffset, title = 'Grover Cleveland', text = 'Cleveland', color = labelColor, textcolor = labelTextColor, style = labelStyle, location = labelLocation, size = labelSize, show_last = 1)

Overview

Columns are offset so each administration appears separately, with a small name label and a dotted zero line. Inputs set column width and the space between columns. Shown terms run from George W. Bush through a second Trump term beginning in 2025. There are no trade signals, entries, or exits.

Details

Published by

everget on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Screeners & dashboards

Markets

Any symbol

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

pinepinescripttechnical-indicatorsindicatorsoscillatorbandsaveragetradingviewindicatormoving-average

Settings

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

SettingTypeDefaultVariable
Columns Widthint15width
Space Between Columnsint150space
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 scans a pasted list of symbols for RSI directional momentum and shows matching long and short signals in a table in a separate pane. The user chooses continuous break, continuous retracement, flip break, flip retracement, divergence, or hidden d

Indicator v6 Oscillators & momentumDivergence
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - RSI Directional Momentum Scanner

Tables-001

by ricardosantos79
261 stars

This indicator builds a TradingView table in a separate pane and fills its cells with fixed placeholder text according to whether each row and column index is even or odd. Users set the table position, the number of rows and columns, and the background, frame,

Indicator v4 Screeners & dashboards
Updated 4 years ago · None stated GitHub repository of Tables-001
257 stars

Donald SPX - Options Trading is an indicator designed to assist SPX index option traders by tracking session benchmarks and multi-timeframe moving average data. It calculates a 200-period weighted moving average (WMA) and requests multi-timeframe bar data from

Indicator v5 Moving averagesScreeners & dashboards Repaints
Updated 6 weeks ago · None stated GitHub repository of Donald SPX - Options Trading

Index Member Distribution

by TradersPost
218 stars

Calculates and plots a weighted histogram of constituent returns for major market indices (NDX, SPX, DJIA, and RUT) in a separate pane. Each histogram bin reflects the summed weights of members within that percentage return bracket. The script renders vertical

Indicator v6 Screeners & dashboards
Updated 3 months ago · None stated GitHub repository of Index Member Distribution

KamaFama

by Mastaaa1987
141 stars

KamaFama is an indicator that translates a Freqtrade trading strategy into Pine Script for visualization. It combines Kaufman Adaptive Moving Average (KAMA), MAMA/FAMA calculations derived via Hilbert Transform, Williams %R, and correlation trend filters to ev

Indicator v6 Moving averagesOscillators & momentum
Updated 6 weeks ago · MIT GitHub repository of KamaFama
114 stars

Calculates normalized reversal metrics across up to ten Forex currency pairs using user-selected moving average methods, including HarmonicMA, EMA, SMA, or WMA. The indicator identifies overbought, oversold, and mean-crossing conditions using a configurable th

Indicator v4 Screeners & dashboardsMean reversion
Updated 1 year ago · None stated GitHub repository of Multi-Pair Trend Reversal Widget

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