Indicator · Pine Script v5 · Own pane

PipAtlas Balance & Equity Curve (trade log)

by pipatlas26

This indicator plots a custom equity curve and drawdown profile based on a user-defined trade log string.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code48
Settings4inputs
LicenceMIT
Last update12 days ago12 Nov 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

48 lines of Pine Script v5 from tradingview/pipatlas-balance-equity.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

pipatlas-balance-equity.pine
//@version=5
//  PipAtlas Balance & Equity Curve — https://pipatlas.com/tools
//  TradingView cannot read your broker account, so this draws the equity
//  curve of a trade log you enter: starting balance plus one result per
//  trade in percent. Shows peak, max drawdown and the underwater stretch.
//  Education only, never financial advice.
indicator("PipAtlas Balance & Equity Curve (trade log)", overlay=false, max_lines_count=500, max_labels_count=50)

i_start = input.float(10000.0, "Starting balance", minval = 1)
i_log   = input.string("2.0, -1.0, 3.5, -0.5, 1.5, -2.0, 4.0, 1.0", "Trade results (% each, comma separated)", tooltip = "One closed-trade result in percent, separated by commas. Example: 2.0, -1.0, 3.5")
i_up    = input.color(color.teal, "Equity line")
i_dn    = input.color(color.red, "Drawdown shading")

var float eq[] = array.new_float()
var float peak[] = array.new_float()
if barstate.isfirst
    float e = i_start
    float pk = i_start
    array.push(eq, e)
    array.push(peak, pk)
    for part in str.split(i_log, ",")
        float r = str.tonumber(part)
        if not na(r)
            e := e * (1.0 + r / 100.0)
            pk := math.max(pk, e)
            array.push(eq, e)
            array.push(peak, pk)

var line eqLine = na
var line ddLine = na
if barstate.islast and array.size(eq) > 1
    int n = array.size(eq)
    float step = math.max(1, math.round(n / 30.0))
    // equity polyline across the last n spaced bars
    for i = 1 to n - 1
        int xb = bar_index - (n - i) * step
        int xa = bar_index - (n - i + 1) * step
        line.new(x1 = xa, y1 = array.get(eq, i - 1), x2 = xb, y2 = array.get(eq, i), color = i_up, width = 2)
        line.new(x1 = xa, y1 = array.get(peak, i - 1), x2 = xb, y2 = array.get(peak, i), color = i_dn, width = 1, style = line.style_dotted)
    float fin = array.get(eq, n - 1)
    float pk2 = array.max(peak)
    float maxdd = 0.0
    for i = 0 to n - 1
        maxdd := math.max(maxdd, (array.get(peak, i) - array.get(eq, i)) / array.get(peak, i) * 100.0)
    label.new(x = bar_index, y = fin, text = "Equity " + str.tostring(fin, "#.##") + "  (max DD " + str.tostring(maxdd, "#.#") + "%)", style = label.style_label_left, color = i_up, textcolor = color.white, size = size.small)
    label.new(x = bar_index - n * step, y = i_start, text = "Start " + str.tostring(i_start, "#.##"), style = label.style_label_right, color = color.gray, textcolor = color.white, size = size.small)

plot(array.size(eq) > 0 and barstate.islast ? array.get(eq, array.size(eq) - 1) : na, "Final equity", display = display.data_window)

Overview

Users specify a starting balance and enter comma-separated percentage returns for closed trades. The script parses the input, calculates compounding balance step-by-step, tracks peak values, and computes maximum percentage drawdown. It visually draws the resulting equity curve and peak levels in a separate pane using line drawings on the recent bars, accompanied by summary labels. Settings permit adjustments to the starting account size, trade results list, line colors, and style.

Details

Published by

pipatlas26 on GitHub

Draws

Separate pane below the chart

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

expert-advisorforexmetatrader5mql4mql5pinescriptposition-sizingrisk-managementtrading-indicatorstradingview

Settings

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

SettingTypeDefaultVariable
Starting balancefloat10000.0i_start
Trade results (% each, comma separated)string2.0, -1.0, 3.5, -0.5, 1.5, -2.0, 4.0, 1.0i_log
Equity linecolorcolor.teali_up
Drawdown shadingcolorcolor.redi_dn
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

947 stars

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. Columns are offset so each administration appears separately, with a s

Indicator v6 Screeners & dashboards
Updated 5 weeks ago · GPL-3.0 GitHub repository of Presidents Performance

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 5 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 2 months ago · None stated GitHub repository of Donald SPX - Options Trading

Index Member Distribution

by TradersPost
228 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 4 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 2 months ago · MIT GitHub repository of KamaFama

More Screeners & dashboards scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers