Links

Strategy Testing

Best practices for testing any trading strategy on Tradingivew.com

Strategy Testing

Guidelines and best practices when testing a strategy on Tradingview.com
This portion examines the tradingview trading platform and the strategy testing engine that enables users to test the historical success and potential revenue generated over a strategy's lifetime. The MarketGod Indicator includes a strategy backtest which users can use in tandem or independently of the Indicator.
  • General differences between the Strategy and Study functions on Tradingview
  • How to set the given settings of a strategy to receive the most accurate results
  • How to to interpret the results seen when backtesting a Tradingview strategy
Tradingview.com is an online charting platform that offers a powerful solution and test trading engine for users looking to build any trading approach of their own. Tradingview users have the ability to define, develop and refine their own strategies and they can be applied to all general strategies on tradingview.com and the comprehensive results are illustrative of the success one sees from a given trading approach.

Studies Vs Strategies On Tradingview

Here we evaluate and differentiate the differences between strategies and studies on tradingview.com
Tradingview differentiates strategies from studies in multiple ways that will be discussed below. If unfamiliar with the topic, know that Studies and Indicators are the same thing. Any Oscillator, Chart overlay, indicator, etc is a STUDY in technicality. Studies differ directly in that strategies are reactive to market environment and variables change given the situation, while studies will be more of a 'rinse, repeat' kind of set-up in which we can generate alerts from in which we use to apply a strategy to.
In essence, indicators are used to READ a market, while strategies are used to PLAY the market.
Indicators can not place orders or cannot be modified to fit a given environment. They will always give the same result at the same time.
Tradingview's native programming language Pine script, enables traders to develop algorithms they can apply as both indicators and strategies. Some users are unaware that indicators are completely unique from strategies and do not imply a given result from a reading or measurement taken. In their own functionality the call for an indicator over a strategy actually leads to almost a different process entirely for defining the price movement and what the intended result is. For one, indicators can establish alerts to be set that the trader will follow and receive on their mobile device when triggered. Strategies however, are limited in this ability and cannot fire alerts.
The challenge is that of the Tradingview users testing their strategies do not know how to interpret the results provided by Tradingview, which we aim to accomplish by showing specific examples and methods of testing, a standard of practice for our users and all Tradingview users to follow, along with various resources for reading further into this subject.
Some of the examples below are directly from the Tradingview blog, and resources provided by the PineCoders Community (Tradingview endorsed group & pine script MOD’s). These items will be cited formally and linked.
The strategy report makes interpreting the success of a strategy relatively easy with its first look as we see above. The initial reporting metrics appear and logically make sense as well. But once we pivot over to the list of trades, Tradingview has identified 4 components that are specified in this blog post

Strategy Settings and Associated Terms

Terms
Definitions
Profit (1)(from image)
This shows the profit per trade and the percentage gain or loss of that trade.
Cumulative Profit (2)(from Image)
This shows the total profits or losses of the strategy after closing a trade and the percentage gain or loss of the strategy over time.
Run-up (3)(from Image)
This shows the maximum possible profit of the trade according to the strategy as well as the maximum percentage gain.
Draw down (4) (from Image)
This shows the maximum possible loss of the trade according to the strategy as well as the maximum percentage loss.
Definitions for Terms Used Across Tradingview Settings and Reporting Strategies
It is important to be familiar with the terminology of the various settings and customization to parameters the trader has direct ability to change when back-testing. Many of these settings exponentially impact the result of th
Slippage
Slippage refers to the conflict between the expected price of a deal and the price at which the trade is executed. Slippage can occur at any time but is most prevalent during periods of volatility when market orders are used. It can also occur when a large order is executed
but there isn't enough volume at the chosen price to maintain the current dictation /ask spread.
Pyramiding
Pyramiding involves adding to profitable views to take reward of an instrument that is performing well. It allows for large profits to be made as the status grows. Best of all, it does not have to increase jeopardy if performed properly.
Normal Candlesticks (OHLC) are the only input we recommend using for back-testing any Tradingview strategy.
Non-standard chart types can provide traders with alternative ways of interpreting price action, but they are not designed to test strategies or run automated traded systems where results depend on the ability to enter and exit trades at precise price levels at specific times, whether orders are issued manually or arithmetically. Ironically, the same characteristics that make non-standard chart types interesting from an analytical point of view also make them ill-suited to trade execution. Why? Because of the dislocation that a synthetic view of price action creates between its non-standard chart prices and real market prices at any given point in time. Switching from a non-standard chart price point into the market always entails a translation of time/price dimensions that results in uncertainty—and uncertainty concerning the level or the time at which orders are executed is detrimental to all strategies.
Generally, these are pretty straightforward terms that are returned by the Trading View engine but you need to be able to understand what is going on with the numbers in it to understand how your orders succeeded in your given Trading approach and strategy. Below is an included glossary to reference the different meetings associated with each term when running your strategy and how you can use them to evaluate the performance.

Measuring The Performance Of Any Strategy

Understanding the definitions of these terms will ultimately add to your general understanding of your strategies performance performance
As you may know by now, back-testing a strategy is a key component in solidifying the base to your overall strategy, which makes the interpreting of its performance report all that more important.
The Strategy Performance Reports appear on the bottom of your Tradingview charts in the management panel, with the tab location next to the Pine Script Terminal. The report itself contains
  1. 1.
    The Strategy Performance Overview
  2. 2.
    An in-depth Strategy Performance Summary
  3. 3.
    A List of Trades that were entered and traded
Many of these performance details are self explanatory, That said, one of the reasons we wanted to write this guide. was because there are a few generalizations and inaccurate assumptions made about the meaning of a few performance details to clear up. These are items to consider when interpreting them on a case by case basis. Below, we touch on the terms referenced and how they could be accurately interpreted on a general level.

Strategy Testing Results - By Page

The Overview Page

The Strategy Testing 'Overview' Page appears when running a test strategy on Tradingview.com
#
Term
Definition
1
Net Profit
The total percent gained in a strategy. You want this to be as high as possible. Measured after fees
2
Number of Trades Entered
Variable on your time frame traded and the frequency of trading. An adequate sample size in statistical textbooks would say aim for 30 or more for the period you are testing. Ultimately, the frequency is your preference on its result.
3
Percent Profitable
Note, this is NOT how good or bad your strategy is. While ideally you want 40%+ win rate, there are cases in which you can win 80% of your trades but still lose money overall on the total return. The difference is in the scale and size of the wins and losses. if the weight of the losses is substantial enough, you can easily be in the red, despite winning the majority of your trades.
4
Profit Factor
The profit factor is a simple ratio between the Gross Profit and Gross Loss values.
5
Max Draw Down
A draw-down is the peak-to-trough decline during a specific recorded period of an investment, fund or commodity security. a draw-down is usually quoted as the percentage between the peak and the subsequent trough.
6
Average Trade Size
Averaged out value of each confirmed trade
7
Length of Bars
Length of average trade for given period

The Performance Summary

Once you have run your backtesting strategy you will see a screen similar to this above the screen showing the results from the strategy approach. Shown here is the Performance Summary found on tab #2 of the report.

Strategy Specific Terms

Terms found on the 'Performance Summary' Page (middle page) on the Strategy Test results
Term
Definition
Net Profit
Profit after Fees
Gross Profit
Profit after fees
Gross Loss
Total sum of all losing trades
Max Draw Down
A drawdown is the peak-to-trough decline during a specific recorded period of an investment, fund or commodity security. a drawdown is usually quoted as the percentage between the peak and the subsequent trough.
Buy & Hold Return
Buy and hold return is a very useful benchmark to help you decide if all your effort is really worth it. It measures what your PNL would be if you just bought an asset and held it until the end of the test. If you cannot beat the buy and hold return then deploying an active trading strategy makes no sense. Of course, as with anything, there are some caveats to this. The first is that if your strategy spends very little time in the market, you might see the reduced risk of getting caught in a large downturn as a benefit. Additionally, depending on the length of your test, you may choose to ignore the buy and hold returns as it may not represent a clear comparison of the performance through different market regimes/cycles.
Sharpe Ratio
Sharpe Ratio refers to the proportional return you receive for holding a level of risk over a specific period of time.
Profit Factor
The profit factor is a simple ratio between the Gross Profit and Gross Loss values.
Max Contracts Held
Max positions open at one time self explanatory. Variable on pyramids as well
Open PL
If you still have an open position at the end of your backtest, the current PnL for that position will be listed here.
Commission Paid
Self explanatory This is a sum of all the commissions paid.
Total Closed Trades
How Many Trades have closed
Total Open Trades
If the trader is still in a position at time of report
Number Winning Trades
How many trades were won
Number Losing Trades
How many trades were not won
Percent Profitable
Of the trades entered, what percent of them were profitable?
Avg Trade
Average Trade value, regardless of result
Avg Win Trade
Average size of the trades won
Avg Lost Trade
Avg size of trades lost
Ratio Avg Win / Avg Loss
Provides the ratio of the gross loss / gross win value
Largest Losing Trade
Biggest lost in one trade / position
Largest Win Trade
Biggest gain in one trade / position
Avg # Bars In Trades
Average length of trade position
Avg # Bars In Winning Trades
Average length of winning trades
Avg # Bars In Losing Trades
Average length of losing trades
In conclusion, the final tips we have for trading are listed below. This guide will ideally be added to over time so remember to check back from time to time in the event any items have changed.

Best Practices for Strategy Testing on Tradingview

  1. 1.
    Use OHLC (normal) candles
  2. 2.
    Always make sure the 'recalculate on every tick' is UNCHECKED in the settings panel
  3. 3.
    Set slippage to reflect the fees you experience per trade
  4. 4.
    Remember that a high percentage of trade profitability DOES NOT ensure the strategy is solid. A strategy with 30% win-rate can yield higher return than one with 70%+. At the end of the day, the ONLY THING THAT MATTERS IS YOUR TAKE HOME PROFIT.

Further Reading into Strategies

Please be sure to review our legal policies and disclaimers before trading any financial securities with any content put forth by our team and organization

Automation

Plus Other External Tools
Automation for our tool has always been the goal. In 2020 we are launching an offering through Trendspider, which will enable users of Trendspider to do so on their platform.
In addition to the Trendspider partnership, we are hoping to ultimately automate the entire process with a bot we offer straight from our site, but at this time, the project is only in infancy and not ready to be shared with our user base. Users can follow this project once we announce it officially towards the end of 2020.
At this time, to maximize your time spent on setting or changing alerts, automating your trading, or just adding more value to MarketGod, we recommend the following tools.
If you'd like to have a tool added to this list, let us know via email at [email protected]o