Code Library / Risk Management

Pine Script Equity Curve

Track equity curve with drawdown visualization.

Language: Pine Script · Category: Risk Management · Tags: equity curve, drawdown, Pine Script, strategy, performance

Source code

//@version=5
indicator("Equity Curve",overlay=false)
var float eq=10000, var float peak=10000
if ta.crossover(ta.ema(close,10),ta.sma(close,50))
    eq+=eq*0.01*(close>open?2:-1)
peak:=math.max(peak,eq)
plot(eq,"Equity",color.green,2); plot(peak,"Peak",color.gray)

How to use this snippet

This is a building block, not a finished trading system. Paste it into your own Pine Script project, compile it, and test it on a demo account with your broker's real spreads before relying on it. You can convert it to MQL4 or MQL5 with the Pine Script converter.

Related snippets