Video summary
How to Backtest a Trading Strategy on Tradingview
Main summary
Key takeaways
Finance-focused summary (backtesting on TradingView)
The video explains how to quickly backtest a trading strategy on TradingView using historical data (instantly, without waiting months/years) and how to evaluate results using TradingView’s built-in strategy tester outputs.
Instruments / tickers / assets mentioned
- Vanguard S&P 500 (used as the example security; ticker not explicitly provided)
- S&P 500 (referenced again for the date-range backtest)
Trading strategy framework (step-by-step)
A simple moving average crossover strategy is implemented in TradingView Pine Script.
Indicators / variables
ema20: 20-day EMAema50: 50-day EMA- EMA is calculated using close (explicitly noted: “best to read from the close”).
Signal logic
- Long condition:
ema20is aboveema50 - Short condition:
ema20is belowema50
Order logic
- Enter long using
strategy.entry(...):- name:
"entry long" - side:
strategy.long - size: 1000 shares
- execution trigger:
when = long
- name:
- Enter short similarly using
strategy.entry(...):- side:
strategy.short - size: 1000 shares
- execution trigger:
when = short
- side:
Closing positions (to prevent constantly opening new trades)
- Use
strategy.close:- close long when
shortis true - close short when
longis true
- close long when
Backtest execution
- Use “Add to chart” to run the backtest.
Backtest period control (explicit timeline example)
The creator shows how to restrict testing to a specific date range using Pine Script timestamps.
Example shown
- Start: 2019 August 1
- End: 2020 (set to an August endpoint per description)
Execution logic
An if block runs the strategy only when:
time >= startandtime <= end
Performance / evaluation metrics mentioned (TradingView tester)
TradingView’s strategy tester tabs are highlighted, including:
- Equity curve
- Net profit
- Number of trades
- Max drawdown
- Average trade
- Trade list (every trade with execution timing/details)
It also notes results can extend back to the 1970s unless restricted.
Plotting / visualization enhancements (for indicator verification)
To verify indicator behavior visually:
- Use
plot()to display moving averages - Set
overlay=trueto show indicators directly on the price chart
Key recommendations / cautions
- Don’t rely on claims like “100% win rate”; test your own strategy on historical data and compare performance.
- Even though the code is described as “basic,” the video emphasizes validating entry/exit placement using chart markers and tester outputs.
Disclosures / disclaimers
- A not financial advice disclaimer is not explicitly stated in the provided subtitles.
- TradingView is mentioned as free and not requiring a paid subscription.
Presenters / sources
- Presenter: Unspecified individual (YouTube creator; no name given in subtitles)
- Source platform: TradingView (Pine Script; built-in functions like
ema,strategy.entry,strategy.close,plot, and timestamp utilities)