Quantitative Backtesting Panel + ROI Table - LongsThis script is an aggregate of a backtesting panel with quantitative metrics, ROI table and open ROI reader. It also contains a mechanism for having a fixed percentage stop loss, similar to native TV backtester. For longs only.
Backtesting Panel:
- Certain metrics are color coded, with green being good performance, orange being neutral, red being undesirable.
• ROI : return with the system, in %
• ROI(COMP=1): return if money is compounded at a rate of 100%
• Hit rate: accuracy of the system, as a %
• Profit factor: gross profit/gross loss
• Maximum drawdown: the maximum value from a peak to a successive trough of the system's equity curve
• MAE: Maximum Adverse Excursion. The biggest loss of a trade suffered while the position is still open
• Total trades: total number of closed trades
• Max gain/max loss: shows the biggest win over the biggest loss suffered
• Sharpe ratio: measures the performance of the system with adjusted risk (no comparison to risk-free asset)
• CAGR: Compound Annual Growth Rate. The mean annual rate of growth of the system of n years (provided n>1)
• Kurtosis: measures how heavily the tails of the distribution differ from that of a normal distribution (symmetric on both sides of mean where mean=0, standard deviation=1). A normal distribution has a kurtosis of 3, and skewness of 0. The kurtosis indicates whether or not the tails of the returns contain extreme values
• Skewness: measures the symmetry of the distribution of returns
- Leptokurtic: K > 0. Having more kurtosis than a normal distribution. It's stretched up and to the side too (2nd pic down). High kurtosis (leptokurtic) is bad as the wider tails (called heavy tails) suggest there is relatively high probability of extreme events
- Mesokurtic: K =0. Having the same kurtosis as a normal distribution
- Platykurtic: K < 0. Having less kurtosis than a normal distribution. This suggests there are light tails and fewer extreme events in the distribution
- Skewness is good: +/- 0.5 (fairly symmetrical)
- Skewness is average: -1 to -0.5 or 0.5 to 1 (moderately skewed)
- Skewness is bad: > +/- 1 (highly skewed)
Evolving ROI table:
- The table of ROI values evolve with the year and month. The sum of each year is given. Please avoid using it on non-cryptocurrencies or any market whose trading session is not 24/7
Open ROI reader:
- At the top center is the open ROI of a trade
Backtest
Regression Channel, Candles and Candlestick Patterns by MontyRegression Candles by ugurvu
Regression Channel by Tradingview
All Candlestick Patterns By Tradingview
This script was combined for a friend of mine who needed this.
This Script has regression candles by ugurvu, Regression channel and Candlestick patterns by tradingview.
The intention was to fuse these together so more information can be processed on the cost of a single indicator.
EMA Cross (data chaining template)Hello Traders! This is the source code for a simple EMA Cross indicator that can be chained to other indicators or another instance of itself as a filter.
The code is fully commented to guide you in building your own chain of indicators based on your ideas and trading plans.
All the best,
Val - Protervus Trading
Unicorn X-AlgoUnicorn X-Algo is a multifunctional trading indicator. It is designed to help traders make real-time decisions using quantitative models.
Its core is a trend trading strategy based on our enhanced Trailing Stop-Loss algorithm. This strategy provides the user with position entry and exit signals. It is customizable and has a built-in instant backtesting feature.
For those who have difficulty with finding the good settings the indicator has the Automatic Mode. In this mode, there is no need for the user to adjust any settings. The indicator calculates optimized trading signals automatically.
In addition, the indicator provides a number of useful tools that aim to provide additional confirmation to the trading signals. They include: support and resistance levels forecast, price range prediction and institutional activity detection.
The script can send real-time alerts to the user’s Email and to the cell phone via notifications in the TradingView app.
The indicator can be used for various types of trend and swing trading, including positional trading, day trading and scalping.
Unicorn X-Algo allows users to:
forecast direction of trends with BUY and SELL signals;
determine the right time to close a position;
detect institutional activity in the market;
forecast key support and resistance levels;
predict the future price range for any market;
customize any settings and do a backtest with one click;
see historical trades on the chart;
use the fully Automatic Mode where the algorithm optimizes all its settings itself.
When using this script, keep in mind that past results do not necessarily reflect future results and that many factors influence trading results.
FEATURES
Trading signals
The feature calculates trend or swing entry and exit signals. The underlying strategy does not use fixed Take-Profit levels. It trails the price with a Trailing Stop-Loss to get as many pips as possible from price movements.
The feature is based on our custom Volatility Stop algorithm. It uses linear regressions instead of averaging. As our practice shows, this helps to reduce signal lag while keeping the number of false signals low.
Trading signals are customizable with Sensitivity and Trade Length parameters which determine the trading signals frequency and width of the Trailing-Stop levels, respectively.
Automatic Mode
The Trading Signals function has an automatic mode. When it is turned on, you do not need to adjust the trading signals settings. The algorithm tries to calculate the best settings automatically using an optimization algorithm.
In this mode, Buy and Sell signals are displayed as green and red triangles respectively. There are two types of exit signals displayed as circles and crosses. A circle signal means that a price reversal is expected and you can partially close the position. A cross signal means that a trading signal in the opposite direction is expected soon and you can partially or completely close your position.
Support and Resistance Levels
Support/Resistance levels forecasting model. The forecasted levels are non-repainting. Once calculated for a specified period in the future (day, week, month, etc.), they don't change during this period.
The feature allows the trader to plan trades and use the forecasted levels as entry levels and targets for opening and closing positions. Both intraday and higher timeframes are supported.
The forecasting model analyses the distribution of the price time series to find clusters in the data. These clusters are then used to make the key price levels forecast.
Big Money Activity detection
The Big Money Activity tool identifies areas on the price chart associated with instructional traders' activity in the market.
Institutional activity in a trending market can be a leading signal for upcoming reversal. Institutions could be fixing their profit, causing the price to move against the current trend.
Institutional activity in a sideways market can be due to positions accumulation and signal a new trend formation.
The algorithm uses tick volume, volume, and volatility data to forecast activity of institutional investors. The method develops the idea described in the Daigler & Wiley (2015) and Shalen (1993) works. It says that when institutional traders actively open or close their positions in the market, a divergence between volume and volatility time-series arises. It can be due to their use of position-splitting algorithms that reduce the impact of their positions on the market.
Trading Range Forecast
Trading Range Forecast feature predicts the price range of an asset for a selected period of time in the future, called Forecast Horizon. It can be the next day or 12-hour trading session. This function works if your chart timeframe is intraday (i.e. the timeframe below "D"). It shows the upper and lower bounds between which the price is going to stay in the upcoming Forecast Horizon period.
Instant Backtesting
After changing any settings, you can immediately see the performance of the strategy on the Instant Backtesting panel. Two metrics are displayed there - the percentage of profitable trades and the total return. This information, as well as the historical trades shown on the chart, will help you quickly and easily evaluate any settings you make.
SETTINGS
TRADING SIGNALS
Trade Length - defines the length of the trades the algorithm tries to make. Recommended values are from 1.0 to 6.0.
Sensitivity - controls the sensitivity of the trading signals algorithm. The sensitivity determines the density of trading signals and how close the trailing-stop levels follow the price. The higher the value of this parameter is, the less sensitive the algorithm is. High values of the Sensitivity parameters (100-500) can help to withstand large price swings to stay in longer price moves. Lower values (10-100) work well for short- and medium-term trades.
TRADING TOOLS
Big Money Activity - turns on and off the identification of the areas associated with institutional traders activity.
SUPPORТ AND RESISTANCЕ LEVELS
Show Support And Resistance Levels - turns on and off support and resistance levels calculation.
TRADING RANGE FORECAST
Show Trading Range Forecast - turns on/off trading range forecasting
Forecast Horizon - sets the period for which the trading range forecast is made
Forecasting Method - allows to choose a forecasting algorithm for the trading range forecast.
BACKTESTING
Use Starting Date - turns on/off the starting date for the strategy and backtests. When off, all available historical data is used.
Starting Date - sets the starting date for the strategy and backtests.
Show Instant Backtesting Dashboard - turns on/off a dashboard that shows the current strategy performance: the percentage of profitable trades and total return.
Leverage - sets the leverage that the strategy uses.
Unicorn QuantDeeply customizable trading algorithm with instant backtesting. It emulates real trading and displays all the actions it takes on the chart. For example, it shows when to enter or partially close a position, move Stop-Loss to breakeven, etc. The user can replicate these actions in their trading terminal in real time. The algorithm uses up to three Take-Profit levels, and a Stop-Loss level that can move in a trade to protect the floating profit.
The script can send real-time alerts to the user’s Email and to the cell phone via notifications in the TradingView app.
The indicator is designed to be used on all timeframes, including lower ones for intraday trading and scalping.
HOW TO USE
Set the Stop-Loss and up to three Take-Profit levels. Choose the rules for moving the Stop-Loss level in a trade. Adjust the sensitivity of the trading signals. And check the backtest result in the Instant Backtesting dashboard. If the performance of the strategy satisfies you, proceed with the forward testing or live trading.
When using this script, please, keep in mind that past results do not necessarily reflect future results and there are many factors that influence trading results.
FEATURES
Trading Signals
The feature calculates Buy and Sell signals for trend or swing trading. The user can change the Sensitivity parameter to control the frequency of the signals. This allows them to be adjusted for different markets and timeframes.
Position Manager
To make the Position Manager setup as easy as possible, the algorithm calculates Stop-Loss and Take-Profit levels in Average True Range (ATR) units. They are self-adjusting for any market and timeframe, since they account for its average volatility .
You don't have to worry about what market you are trading - Forex, Stocks, Crypto, etc. With the self-adjusting Stop-Loss and Take-Profit, you can find settings that work for one market and use the same numerical values as a starting point for a completely different market.
Instant Backtesting
After changing any settings, you can immediately see the performance of the strategy on the Instant Backtesting panel. Two metrics are displayed there - the percentage of profitable trades and the total return. This information, as well as the historical trades shown on the chart, will help you quickly and easily evaluate the settings.
SETTINGS
TRADING SIGNALS
Sensitivity - controls the sensitivity of the trading signals algorithm. It determines the frequency of the trading signals. The higher the value of this parameter, the less trading signals you get and the longer trends the algorithm tries to catch. The lower the sensitivity value, the more signals you receive. This can be useful if you want to profit from small price movements.
POSITION MANAGER
SL - sets the Stop-Loss level measured in ATR units.
TP1, TP2, TP3 - set the Take-Profit levels measured in the ATR units.
Close % at TP1, Close % at TP2, Close % at TP3 - set portions of the open position (as a percentage of the initial order size) to close at each of the TP levels.
At TP1 move SL to, At TP2 move SL to - set the rules for moving the Stop-Loss level in an open trade to protect the floating profit.
Show Open Position Dashboard - turns on/off a dashboard that shows the current Stop-Loss and Take-Profit levels for the open position.
BACKTESTING
Use Starting Date - turns on/off the starting date for the strategy and backtests. When off, all available historical data is used.
Starting Date - sets the starting date for the strategy and backtests.
Show Instant Backtesting Dashboard - turns on/off a dashboard that shows the current strategy performance: the percentage of profitable trades and total return.
Leverage - sets the leverage that the strategy uses.
Breakout Probability (Expo)█ Overview
Breakout Probability is a valuable indicator that calculates the probability of a new high or low and displays it as a level with its percentage. The probability of a new high and low is backtested, and the results are shown in a table— a simple way to understand the next candle's likelihood of a new high or low. In addition, the indicator displays an additional four levels above and under the candle with the probability of hitting these levels.
The indicator helps traders to understand the likelihood of the next candle's direction, which can be used to set your trading bias.
█ Calculations
The algorithm calculates all the green and red candles separately depending on whether the previous candle was red or green and assigns scores if one or more lines were reached. The algorithm then calculates how many candles reached those levels in history and displays it as a percentage value on each line.
█ Example
In this example, the previous candlestick was green; we can see that a new high has been hit 72.82% of the time and the low only 28.29%. In this case, a new high was made.
█ Settings
Percentage Step
The space between the levels can be adjusted with a percentage step. 1% means that each level is located 1% above/under the previous one.
Disable 0.00% values
If a level got a 0% likelihood of being hit, the level is not displayed as default. Enable the option if you want to see all levels regardless of their values.
Number of Lines
Set the number of levels you want to display.
Show Statistic Panel
Enable this option if you want to display the backtest statistics for that a new high or low is made. (Only if the first levels have been reached or not)
█ Any Alert function call
An alert is sent on candle open, and you can select what should be included in the alert. You can enable the following options:
Ticker ID
Bias
Probability percentage
The first level high and low price
█ How to use
This indicator is a perfect tool for anyone that wants to understand the probability of a breakout and the likelihood that set levels are hit.
The indicator can be used for setting a stop loss based on where the price is most likely not to reach.
The indicator can help traders to set their bias based on probability. For example, look at the daily or a higher timeframe to get your trading bias, then go to a lower timeframe and look for setups in that direction.
-----------------
Disclaimer
The information contained in my Scripts/Indicators/Ideas/Algos/Systems does not constitute financial advice or a solicitation to buy or sell any securities of any type. I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from the use of or reliance on such information.
All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, backtest, or individual's trading does not guarantee future results or returns. Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
My Scripts/Indicators/Ideas/Algos/Systems are only for educational purposes!
TTP RSI drawdownThis indicator offers a way to trade the RSI drawdown combined together with its value.
Parameters
- Lookback. How many candles in the past are used to calculate the drawdown of the RSI
- RSI strength and timeframe
- Lower and Upper RSI limits. These are used to colour the drawdown chart, the greener the closed to your specified lower limit and the more red the closer to the upper limit. These limits are also used to confirm that the signal occurs with an RSI value within the given limits.
- Signal threshold. Buy signals will only be triggered when the drawdown of the RSI is higher than the provided value.
Buy signals
The signal will trigger in white color and will plot a 1 to allow backtesting.
TradingView alerts can be set for buy signals.
Buy signals will be trigger only when:
- RSI value is within the provided lower and upper limit values
- RSI drawdown is higher than the provided threshold.
Features
- Back-testable (plots 1 for buy)
- TV alerts
Chart modes
- show RSI
- show highest RSI
- show RSI drawdown
In the short time I've been playing with this new idea I noticed it can be used both for swing trading and for long term analysis like for example finding market bottoms.
Here's an example setup to find BTC past market cycle bottoms:
- load a chart with INDEX:BTCUSD
- set the chart timeframe to daily
- set the chart to logarithmic scale
- zoom out to see the full chart
- add the RSI drawdown indicator
- use the following parameters in the indicator: timeframe: week, gaps: off, show RSI drawdown: on, lookback:30, length:14, lower: 20, upper: 30: threshold: 40
Easy Backtester PROWHAT IS EasyBacktester ?
EasyBacktester is a tool that helps you backtest trading strategies built by yourself with an included strategy builder and a multitude of options.
From within the parameters of the tool, you can specifically pick your entry settings across 12 most common indicators, such as "RSI", "MACD", "Moving Averages" etc... Then you can immediately visualise your setup's Stop-loss & Take Profit, your expected Profits & Loss and a lot of other statistics for your entry strategy. Once you are satisfied with your entry strategy, you are given a set of tools to optimize your setup using stop-loss rules, take profits rules, partial profits, trailing-stops, entry timing...
WHY IS THIS TOOL DIFFERENT ?
EasyBacktester is a backtesting engine with no coding skills required. TradingView allows for "Strategy Scripting" using PineScript, which is not an option for non-coder audience. EasyBacktester fills this gap and allow non-coders to get an idea of how their trading strategies may perform using mouse clicks only.
Some similar attempts have been made on TradingView, allowing some limited options, but none have the same capabilities EasyBacktester offers, for instance, as of April 2022 these features have not been seen in any other TradingView tools:
- partial take profits
- leverage simulation
- a multitude of trailing stop-loss possibilities including trail triggers and trail parameters
- visualisation of entries including stop-loss, take profits, partial take profits, and trailing stops. One can now visualize such complex setups.
- visualisation of Profits & Loss
- time in trade
- wait strategy after a signal: for example, when RSI is oversold, "WAIT until price retraces 100% of the original signal" amongst other possibilities
QUICK START GUIDE:
STEP 1: DEFINE YOUR SIGNAL STRATEGY
From the settings of the tool, find the "SIGNALS STRATEGY" section.
Select a type of entry you wish to simulate, for example "LONGs", and activate the checkbox right before "Simulate".
Right below, you will find 4 signal builder for you to play with and pick your strategy accordingly.
For example, to simulate a signal when RSI is oversold, follow these steps:
- On the 1st multiple choice box, select "RSI"
- On the 2nd multiple choice box, select "is below..."
- On the 3rd multiple choice box, select "OverSold level"
Don't forget to activate this rule by checking the checkbox in front of it.
After this first step, one should immediately see the chart affected with some plots. The dots represents the signal entry defined by the rule we just created, and the red/green boxes visually represent trades that could have been taken with this signal which, in this example, occurs "when RSI is below oversold level". Note that all specific parameters for RSI including its specific "oversold level" is customisable at the end of the tools settings along with all other indicators settings.
STEP 2: STATISTICS
By default, the "APPEARANCE" section only plots potential entry signals (materialized by dots) and actual entry boxes (materialized by red/green boxes).
But the user can easily add other precious statistics to the chart, and obviously the most important one for backtesting: Profits & Loss (P&L).
In the "STATISTICS" section please check the "P&L" box to see appear a chart of the simulated P&L for our example. You should immediately see a new graph below the chart representing the evolution of the P&L after each entry.
Other statistics are available to the user, including: Equity, Number of Trades, Time in Position, Number of trades Won, Number of trades Lost, Number of trades Stopped.
Play around with those to see them plotted on your chart.
STEP 3: OPTIMIZE YOUR ENTRY
Under the "ENTRY STRATEGY" section, one can pick how to enter AFTER the signal, which provides the user with an extensive flexibility to pick its timing.
Here there are a various set of choices offered, ranging from the default "Market Order at Next Candle Open", to "Limit Order: at signal's candle open" or even "Stop-Buy: at break of last candle high". As its name suggests, this option allows you to actually wait before randomly enter in trade.
It is important to also note that the user can totally prevent entry if the conditions are not filled after a customizable number of candles represented in "Max bars to wait for entry" (default being 1, meaning the engine will wait the condition to be filled during only 1 candle)
STEP 4: MANAGE YOUR RISK
Under the "RISK MANAGEMENT" section, the user is given a series of options to set the amount (s)he would like to risk.
This is extremely important to set, and is the result of a combination of customizable options including:
- the Initial Capital of the account
- the amount to risk per trade, and HOW to risk it: some fixed % the initial equity or adjust the stop-loss to the desired risk ?
- use of leverage or not
- initial stop-loss, as well as minimum and maximum
- trailing stop-loss: what should trigger the trailing ? and by how much should the engine trail ?
STEP 5: HAVE AN EXIT PLAN
Under the "EXIT STRATEGY", the user can define how to exit the trade.
For instance, here again a lot of options are given:
- Take Profit: exit at some level of profits defined by a multiple of the stop-loss, or a multiple of the ATR, or some % or points
- Partial Profit taking before exit
- Panic close position after some time spent on the trade
STEP 6: FURTHER OPTIMIZATIONS
Under the sections "Commissions" & "Calendar & Sessions", one can simulate real trading conditions by including commissions fees as well as filtering actual dates and trading sessions. These sections are straightforward for any user to use.
SETP 7: INDICATORS SETTINGS
Since EasyBacktester uses a predefined set of indicators to get started, those indicators are also customizable in the last section of the settings. Here, one can easily customize RSI periodicity, MACD lengths, Moving averages types & lengths, ATR, etc...
STEP 8: GOING FURTHER
This is only a start to give users an overview of how various options affect their trading performance. But of course, each trader has its special recipe and specific detailed setup that is not possible to embed in a single tool. For advanced simulation, EasyBacktester provides plug & play connectors for advanced users. Namely, there are 3 connectors:
- signal connector
- trail trigger connector
- exit connector
Each of these connectors are an opportunity to customize the engine signals, trail trigger and exit choices with the user's own options. This case does require a little bit of coding, but it can easily be implemented by copy-pasting existing resources or with a slight help of a professional. In fact, the only conditions to build a proper connector is to export a plot with the numbers 1 (for signals), 2 (for trigger trails) and 3 (for exits). Here is an example of custom SIGNAL connector compatible with EasyBacktester, to produce a signal when last RSI was below 30 and current RSI reads above 30:
============================================================
//@version=5
indicator("My custom RSI signal")
// when previous RSI 14 was below 30 and current RSI 14 is above 30, set "custom_signal" to 1, otherwise set "custom_signal" to 0
custom_signal = ta.rsi(close, 14) < 30 and ta.rsi(close, 14) > 30 ? 1 : 0
// Export a plot of "custom_signal", but do not display it
plot(custom_signal, title="my signal", display=display.none)
============================================================
Once this indicator has been built, the user only needs to connect it with EasyBacktester as follow:
1. Open a desired chart, and add both EasyBacktester indicator as well as the custom "My custom signal" we just created above.
2. Open EasyBacktester's settings, and in the first option, there is "Connect signals source" which by default is set to "close". In the multiple choices, find your custom signal which should be named something like "My custom RSI signal: my signal", generally speaking the name is built like this " : ".
3. Now the custom code is connected to EasyBacktester, but we need to indicate the engine we actually want to use it as custom signal.
4. Under the "SIGNALS STRATEGY" section, where we generally build signals rules, there is special rule for this specific connection named "Use external source as entry signal". Just check the checkbox to activate it and see how the chart took our custom signal into consideration.
That's it for the overview of EasyBacktester. Thank you for reading and happy trading :)
Backtesting- IndicatorFor anyone interested, Here is an example of how to put backtesting results into an Indicator. This calculates the same values as you find in the Summary Screen of the built in Strategy backtester. This will use the same result size as the standard backtester i.e. 5 minute chart grabs roughly 1 month of data, 1 minute chart grabs 1 week of data, etc... I tried to keep this as self-contained as possible so I put most of the code for the results in the bottom of the Indicator. The results stop at the last completed trade signal i.e. a Buy has a Sell to it. This is the same indicator I posted earlier with the PCT Trailing StopLoss so you will see that code in here as well. As said in my previous posting, the indicator is just a simple EMA crossover to give it something to do and I would not recommend using this indicator on its own, but instead copy the code to your own indicator if you find it useful. I also left the code in so that you can switch back to a Strategy if you want to verify the results.
Additional Notes:
- The results are within an acceptable margin of error due to the fact that the Indicator is having to calculate based on when the Buy and Sell Signal occur as opposed to when actual trades occur like in the Strategy Backtester
- I was trying to find a way to set the number of Buy Signals to use i.e. show me the results from the past 100 trades but couldn't sort out the logic. I am open to suggestions. Also keep in mind I am not a coder by profession so if you have any ideas on that front, please explain it to me as though I am a 5 year old child and provide code examples if possible :)
- I included the Strategy results in the Screen Shots so that you can see where the results line up.
Additional Additional Note:
This is not financial advice. Use at your own risk.
Backtest HelperAre you tired of being able to see the future while you're backtesting? Have you ever clicked to a higher timeframe in bar replay, only to realize you've just seen everything that's going to happen before you've had a chance to test it? If you've had this problem, Backtest Helper is here for YOU.
All you have to do is set a start date and time, then set your desired timeframe in minutes, then you're off to the races.
For example, if you're a scalper that uses the 15 minute as their higher timeframe, set your start time at the 14th minute of the session you're testing and set your line spacing at 15 minutes. This will mark off every 14th minute on the charts. Now you know the exact moment you can go up to the 15 minute timeframe!
On our 1 minute timeframe, this is how we'd look with the above settings. The Backtest Helper has marked off the 14th, 29th, 44th and 59th minute.
When we go up to our 15 minute, there's no issues. We're seeing the candle we want to see and not the next 15 minute candle.
You can use this for any timeframe. Just make sure you set your start time to at least 1 minute before the close of the candle and your line spacing to the higher timeframe (in minutes) you want to target.
Manual Backtest - Flat the ChartThis script is an utility tool for manual backtesting.
The main problem in backtesting a discretionary strategy is the bias of knowing the future result of the market, in this way all the market will be crushed into a flat line, this way you can avoid bias.
The way to use this indicator is easy and made by 4 step:
Step 1 : add to an asset you won't backtest and put the auto scale on
Step 2 : go to the asset you will backtest and scroll left until the date you want to start
Step 3 : use the replay function of tradingview (15 min chart won't go back more than 18 month)
Step 4: toggle off the indicator or remove from the chart (untill next asset to backtest)
That's not a complex indicator but is what you need to do a fair backtesting
Inverse Fisher Transform ScreenerThis is a Screener for Inverse Fisher Transform on multiple oscillators
This tool is intended to aid you to visually analyse reasonable buy and sell IFT-signal thresholds across multiple tokens and different sources. It will help you speed up the tedious and manual work of trying out different IFT-settings when you're able to review the chart visually to find which values are present the most often and the location of that signal on the chart.
What does it bring to the table, why is it useful?
- Invese Fisher Transform on multiple oscillators such as RSI, MFI, CCI, Stochastic
- Combine multiple sources into one signal, select how it's calculated
- Visually review the chart for good IFT-settings
- 4 dynamic buy labels with different thresholds
- 4 dynamic sell labels with different thresholds
- Buy and sell on signal reversal
- Create your own trade alerts for automation
- Backtester compatible (plots 1 and 2 for buy and sell signals)
- A dynamic table counting amount of signals for each setting
- The labels are automatically updated when you change the values in the settings
How to use?
1. Change signal source and method
2. Change buy and sell thresholds
3. Show/hide additional labels
4. Review chart
5. Change trade settings
6. Backtest
7. Create alerts
Description
With this indicator you're able to visually review the signal strength of one or multiple oscillators processed with Inverse Fisher Transform ( IFT ), combine them and choose the method of calculation when they are combined. This produces a signal which strongly fluctuates between -1 and +1 instead of the more common 0-100 most oscillators uses. The intention is to make the decision making clearer and easier when you decide when to enter or exit a trade. This aims to help you remove the feelings from your trading.
Inverse Fisher Transform was first presented by John Ehlers in Stocks & Commodities V. 22:5 where he proposes to process RSI with the formula for hyperbolic tangent, tanh (x). This transforms the oscillator into a smoother and more compressed version with quicker oscillations.
Zendog SHORT DCA Trigger RSI+StochRSIThis is a script that generates a SELL signal by combining RSI and Stochastic RSI into the same script and that can easily be integrated into an external Backtester like the one I published.
The script uses default values for RSI and Stochastic RSI overbought conditions.
They should be adjusted for specific assets and timeframes so they better match the current trend. Please beware you might overfit settings to match a short timeframe trend (like a few days or hours). If this is the case once the trend changes the signals will not be accurate.
The purpose of this script is to provide some pine code that can be used to further combine multiple indicators into a SHORT Deal Start signal.
Integration with the Zendog Backtster:
- add the backtester on the chart
- add this script on the chart
- in the Zendog backtester Deal start type select "External indicator"
- in the Zendog backtester Indicator source and value select "Zendog SHORT DCA Trigger RSI+StochRSI: SIGNAL"
Zendog LONG DCA Trigger RSI+StochRSIThis is a script that generates a BUY signal by combining RSI and Stochastic RSI into the same script and that can easily be integrated into an external Backtester like the one I published.
The script uses default values for RSI and Stochastic RSI oversold conditions.
They should be adjusted for specific assets and timeframes so they better match the current trend. Please beware you might overfit settings to match a short timeframe trend (like a few days or hours). If this is the case once the trend changes the signals will not be accurate.
The purpose of this script is to provide some pine code that can be used to further combine multiple indicators into a LONG Deal Start signal.
Integration with the Zendog Backtster:
- add the backtester on the chart
- add this script on the chart
- in the Zendog backtester Deal start type select "External indicator"
- in the Zendog backtester Indicator source and value select "Zendog LONG DCA Trigger RSI+StochRSI: SIGNAL"
VictoriaThis indicator visualises different oscillators processed through Inverse Fisher Transform
What is included:
Inverse Fisher Transform on different oscillators
You can combine multiple oscillators into one
The combination of sources can be calculated in different ways
Set different buy and sell signal thresholds
View selected thresholds in the chart
Use TradingView Technicals Buy and Sell signals to dynamically change threshold values
Convert signal to alerts
Multiple filters to allow or block signals
Backtest compatible
Alerts compatible
Two different chart modes:
You can view multiple oscillators in the same chart
You can view trade signals/alerts on the chart from the thresholds you have selected
Description:
With this indicator you're able to visually review the signal strength of one or multiple oscillators processed with Inverse Fisher Transform (IFT), combine them and choose the method of calculation when they are combined. This produces a signal which strongly fluctuates between -1 and +1 instead of the more common 0-100 most oscillators uses. The intention is to make the decision making clearer and easier when you decide when to enter or exit a trade. This aims to help you remove the feelings from your trading.
Inverse Fisher Transform was first presented by John Ehlers in Stocks & Commodities V. 22:5 where he proposes to process RSI with the formula for hyperbolic tangent, tanh(x). This transforms the oscillator into a smoother and more compressed version with quicker oscillations.
Within a bull or bear period of the traded asset the signal have different strengths. To harness this to our advantage we use the combined strength of the TradingView Technical indicator which gives us a Buy, Strong Buy, Sell or a Strong Sell on the selected timeframe and asset. This makes it possible to delay the buy in bearish conditions to only trigger when it is really oversold and also allow the signal be more relaxed and exit the trade sooner. While on the other hand if the condition is bullish the buy signal is relaxed and the sell requires a stronger signal. All of this is possible to change in the indicator to fine tune the settings for the specific asset and timeframe selected. We also have the possibility of blocking the buy signals with different filters.
QFL bull bypassThis bypass indicator triggers plots 1 when the price is above the QFL base.
This can be used as a "bypass" by a consumer indicator that can skip trades when the bypass is triggering.
You can use it for long and short strategies, to prevent using buy or sell signals in areas were the price is either overextended.
QFL works better in 1, 2 or 4 hours timeframes.
Inverse Fisher Transform on RSI for backtest w/alertsThis version of the Inverse Fisher Transform on RSI comes with support for
1) Backtesting with Gavin's backtest script
2) Bypass, you can use another indicator to pause buy signals from this indicator. Just create another indicator that plots "1" whenever you want to activate the bypass on the IFTRSI signal.
3) Independent buy and sell level thresholds. Some tokens perform better with a higher sell level, even levels as high as 0.996, sometimes the buy level can also be relaxed to even 0.6 and get incredible results on the 5 minute chart.
4) alerts for Buy and Sell signals
Make sure you add Gavin's backtest and select external signal and this indicator as the source.
TV signal for DCA backtestThis script allows you to backtest Trading View's "Technical Ratings" (Buy, Strong buy, Sell, Strong Sell) using Gavin's backtest script.
To use it add the backtest script to the chart together with this script and then from the back test settings connect the external indicator. You should select "TV Signal" as the source.
Backtesting works best on the 5m chart, but you can still change this script from its settings to higher timeframes.
Encoding
Buy is 1
Strong Buy is 2
Sell is -1
Strong Sell is -2
In the backtest script you can decide which rating you want to use for open deal and which one for close deal.
For example, if you were backtesting a long bot you could enter a long position when TV signal is Buy (1) and close the deal when TV signal is Sell (-1).
You have the full flexibility to decide which technical rating to use for your backtesting.
Enjoy!
Smart AlertsThis indicator provides back-tested signals and alerts from multiple technical indicators.
No more guessing whether or not you should trust an indicator. See your indicators' past performance at a glance.
No more false alarms. Disable re-painting of signals.
When multiple indicators overlap, a Confluence indicator will print (large triangle). With your settings properly tuned, this will show a HIGH probability of a move.
Current Signal/Alert Options (more to come):
RSI Oversold
RSI Overbought
EMA Crossing Up
EMA Crossing Down
Buy Signal Confluence
Sell Signal Confluence
Instructions:
-Enable/disable individual indicators so you can fine tune one at a time
-Adjust the indicator's settings
-Adjust your trade parameters (Max Wait, Take Profit %). Signals that would have given the desired profit in the time allowed will be painted orange.
-Repeat this process with each indicator until you're satisfied
-Set-up alerts
Smart EMA SignalsThis indicator starts by plotting each time the price action crosses above or below the EMA, of which you can tune the timeframe and duration.
It then takes it a step further and plots whether or not that indicator would have given you a profitable trade, of which you can also tune the parameters (Max wait time, and % Profit).
Once you have your EMA tuned to your liking, set up alerts to notify you of a golden opportunity.
QFL single TF with alertsBacktesting compatible QFL pine script w/alerts
This version of QFL was made based on this one:
From author:
www.tradingview.com
I made the following additions according to my requirements:
- I need to use pine script 4
- I needed to avoid repainting issues so I'm not calling directly security, I'm using the wrapper function.
- There might be still repainting issues when you use "max base age" which uses the function "barssince" so be careful, you can disable it by setting its value to zero.
- Alerts so I can use it for automated trading and bots
- In order to make this signal compatible with the backtest script there's an option provided in the settings. If you enable this option this indicator will plot 1 whenever there's a BUY signal. This will allow the backtest to pick the "QFL Buy" from external indicator so it can perform the backtest.
I recommend some of these settings to start playing with the chart in 15 min / QFL in 1, 2 or 4 hours.
The higher the TF the more conservative.
QFL with 3.5% is pretty popular but you can try higher QFL percentage settings for a more conservative approach.
Study Backtester [MS]Backtest your study like a strategy with our Study Backtester. Visualize your script's performance directly on the chart.
Simple to use, copy-paste a few lines of code (shown below) into your script, then set your script as input to the Study Backtester.
Visualize how your script performs against buy-and-hold over time, and get a nice print out of stats.
Settings
Set your buy and sell signal inputs
Add a stop loss
Choose normal or trailing stop loss
Choose the start date and time for backtesting
Set trading commissions
Use leverage or not
Set carry cost for leveraged trades
Version 1
Only supports buy-sell-buy-sell alternating signals. Any non-alternating signals will be ignored.
Testing begins with 1 share of the asset at your first buy signal.
Things To Note
This cannot enter or exit mid-candle. With the exception of the stop loss feature, which will calculate exits at the exact stop price.
Stops are not treated as stop-orders, but as market-exists at the stop (or trailing stop) price.
This DOES NOT take into account any loss of funds due to liquidation if price goes against you in a margin position.
Short positions are not currently supported.
Only `study` scripts are supported
How To Use
1) Add the following to the bottom your study's code.
//------------------------------------------------------------------------------
// FOR BACKTESTER
plot(buy ? 1 : sell ? -1 : na, title="Signals", display=display.none, editable=false)
2) Make sure `buy` and `sell` variables are assigned appropriately according to your strategy.
3) Add both your study and this script to your chart.
4) Set the "Signals Plot" setting of this script to: : Signals
5) Adjust this script's settings (start date, commission, stoploss, etc) as necessary.
PM us with any questions about this script.
MACD With Trend Filter: Visual Backtest Module TemplateSample Strategy: MACD Crossover with trend filter options
MA Filter : Price Close Above MA, Search for Buy, Price Close Below MA, Search for Sell
ADX Filter : Take trade only when ADX is above certain treshold
MACD Signal : MACD Cross above signal line while under 0 line indicate Buy Signal
MACD Cross below signal line while above 0 line indicate Sell Signal
-----------------------------
Using Alert Module:
Enable Alert --> Enable TV's alert and plot signal to chart
Alert Type --> Set to take Buy only, Sell only or Both alert
----------------------------
Using Backtest Module:
Enable Backtest --> Enable Backtest simulation
Backtest Type --> Set to take Buy only, Sell only or Both
SL Type -->
ATR : Set SL in ATR times Multiplier below/above entry price
Fixed : Set SL in fixed point below entry point (in 'Dollar'). e.g. for Stocks -> 0.5 equals to 50cent while for EURUSD currency -> 0.005 equal to 50 pips
HiLo Bar : Set SL at highest/lowest wick of previous bar plus/minus Fixed point. e.g. EURUSD HiLo=3 and Fixed Point = 0.0005, buy trade will place SL 5 Pips below lowest of previous 3 bar
SL ATR Period --> Set Lookback Period used for SL's ATR calculation
SL ATR Multi --> Set ATR Multiplier for SL
SL Fixed --> Set Fixed Level for SL (Use when SL Type is either Fixed or HiLo Bar)
SL Bar --> Set Number of previous bar to check for SL placement
TP RR Ratio --> Set TP based on RR multiplier. e.g. 2 means TP level will be twice further from entry point compared to Entry-SL distance.
Notes: The point is for preliminary testing, so it only supports 1 trade at a time and no Trailing Stop
----------------------------
Disclaimer:
This script main objective is to create my personal indicator template so that i just have to modify the indicator module for preliminary testing in future.
Testing Alert Module so i can re-use it as template in future study/indicator
Testing Visual Backtest Module so i can re-use it as template in future study/indicator
i believe using Strategy function is a better approach for this but the entry/exit level seems to be hit n miss (at least for me, still trying to figure what i did wrong)
also, i rather code the strategy in other platform where i can use the more accurate tick data if i want to validate backtest statistics.
My study scripts was built only to test/visualize an idea to see its viability and if it can be used to optimize existing strategy.
credit: ADX code are originally from "ADX and DI" by @BeikabuOyaji although i re-wrote so i can have cleaner read and use RMA instead of SMA