MarketHolidaysLibrary "MarketHolidays"
The MarketHolidays library compiles market holidays (including historical special market closures) into arrays, which can then be utilized in TradingView indicators and strategies to account for non-trading days. The datasets were split into different libraries to overcome compiling limitations, streamline the process of removing specific time frames if not needed, and to enhance code execution speed. The timestamps are generated using a custom Python script that employs the 'pandas_market_calendars' library. To build your own set of arrays, you can find the script and instructions at github.com
getHolidays(_country)
The getHolidays function aggregates holiday data from different time periods to create a single array with market holidays for a specified country.
Parameters:
_country (string) : The country code for which to retrieve market holidays. Accepts syminfo.country or pre-set country code in ISO 3166-1 alpha-2 format.
Returns: An array of timestamps of market holidays \ non-trading days for the given country.
Non
Nadaraya-Watson Envelope (Non-Repainting) Logarithmic ScaleIn the fast-paced world of trading, having a reliable and accurate indicator can make all the difference. Enter the Nadaraya-Watson Envelope Indicator, a cutting-edge tool designed to provide traders with valuable insights into market trends and potential price movements. In this article, we'll explore the advantages of this non-repainting indicator and how it can empower traders to make informed decisions with confidence.
Accurate Price Analysis:
The Nadaraya-Watson Envelope Indicator operates in a logarithmic scale, allowing for more accurate price analysis. By considering the logarithmic nature of price movements, this indicator captures the subtle nuances of market dynamics, providing a comprehensive view of price action. Traders can leverage this advantage to identify key support and resistance levels, spot potential breakouts, and anticipate trend reversals.
Non-Repainting Reliability:
One of the most significant advantages of the Nadaraya-Watson Envelope Indicator is its non-repainting nature. Repainting indicators can mislead traders by changing historical signals, making it difficult to evaluate past performance accurately. With the non-repainting characteristic of this indicator, traders can have confidence in the reliability and consistency of the signals generated, ensuring more accurate backtesting and decision-making.
Customizable Parameters:
Every trader has unique preferences and trading styles. The Nadaraya-Watson Envelope Indicator offers a range of customizable parameters, allowing traders to fine-tune the indicator to their specific needs. From adjusting the lookback window and relative weighting to defining the start of regression, traders have the flexibility to adapt the indicator to different timeframes and trading strategies, enhancing its effectiveness and versatility.
Envelope Bounds and Estimation:
The Nadaraya-Watson Envelope Indicator calculates upper and lower bounds based on the Average True Range (ATR) and specified factors. These envelope bounds act as dynamic support and resistance levels, providing traders with valuable reference points for potential price targets and stop-loss levels. Additionally, the indicator generates an estimation plot, visually representing the projected price movement, enabling traders to anticipate market trends and make well-informed trading decisions.
Visual Clarity with Plots and Fills:
Clear visualization is crucial for effective technical analysis. The Nadaraya-Watson Envelope Indicator offers plots and fills to enhance visual clarity and ease of interpretation. The upper and lower boundaries are plotted, along with the estimation line, allowing traders to quickly assess price trends and volatility. Fills between the boundaries provide a visual representation of different price regions, aiding in identifying potential trading opportunities and risk management.
Conclusion:
The Nadaraya-Watson Envelope Indicator is a powerful tool for traders seeking accurate and reliable insights into market trends and price movements. With its logarithmic scale, non-repainting nature, customizable parameters, and visual clarity, this indicator equips traders with a competitive edge in the financial markets. By harnessing the advantages offered by the Nadaraya-Watson Envelope Indicator, traders can navigate the complexities of trading with confidence and precision. Unlock the potential of this advanced indicator and elevate your trading strategy to new heights.
Non Adaptive Moving Average - Quan DaoThis Non-Adaptive Moving Average (NAMA) is my origin work. It came from the issues that I always face when using existing famous MA like EMA or RMA:
- What length should I choose for the MA for this security?
- Is there a length that works for multiple timeframes?
- Is there a length that works for multiple securities in multiple markets?
Choosing the right length for an MA is a tedious and boring work and is very subjective. One day in early 2023, I decided to create a new MA that will not be dependant a lot (non-adaptive) on the length of it, to make my life a little bit easier. The idea came from the formula of EMA and RMA:
ma = alpha * src + (1 - alpha) * ma
in which,
alpha = 1 / length for RMA
alpha = 2 / (length + 1) for EMA
I decided to use a constant alpha for the formula, which happened to be: 1.618 / 100 (i.e., golden ratio / 100)
This NAMA is using the length in the start only, after running for a while the MA value will be the same for every value of its length, which resolves good my 3 questions above.
The application of this NAMA is wide, I think.
- It can be used like a normal MA but you don't have to choose its length anymore.
- It can be used like EMA in DEMA, TEMA (I called it DNAMA, TNAMA)
- It can be used in calculating some famous indicators (RSI, TR, ...) so that these indicators will not be dependant on the length as well
In this example script, I included an EMA (in blue color) as well so that you can see how the EMA changes and NAMA stays the same when changing the value of its Length.
Smoothing R-Squared ComparisonIntroduction
Heyo guys, here I made a comparison between my favorised smoothing algorithms.
I chose the R-Squared value as rating factor to accomplish the comparison.
The indicator is non-repainting.
Description
In technical analysis, traders often use moving averages to smooth out the noise in price data and identify trends. While moving averages are a useful tool, they can also obscure important information about the underlying relationship between the price and the smoothed price.
One way to evaluate this relationship is by calculating the R-squared value, which represents the proportion of the variance in the price that can be explained by the smoothed price in a linear regression model.
This PineScript code implements a smoothing R-squared comparison indicator.
It provides a comparison of different smoothing techniques such as Kalman filter, T3, JMA, EMA, SMA, Super Smoother and some special combinations of them.
The Kalman filter is a mathematical algorithm that uses a series of measurements observed over time, containing statistical noise and other inaccuracies, and produces estimates of unknown variables that tend to be more accurate than those based on a single measurement.
The input parameters for the Kalman filter include the process noise covariance and the measurement noise covariance, which help to adjust the sensitivity of the filter to changes in the input data.
The T3 smoothing technique is a popular method used in technical analysis to remove noise from a signal.
The input parameters for the T3 smoothing method include the length of the window used for smoothing, the type of smoothing used (Normal or New), and the smoothing factor used to adjust the sensitivity to changes in the input data.
The JMA smoothing technique is another popular method used in technical analysis to remove noise from a signal.
The input parameters for the JMA smoothing method include the length of the window used for smoothing, the phase used to shift the input data before applying the smoothing algorithm, and the power used to adjust the sensitivity of the JMA to changes in the input data.
The EMA and SMA techniques are also popular methods used in technical analysis to remove noise from a signal.
The input parameters for the EMA and SMA techniques include the length of the window used for smoothing.
The indicator displays a comparison of the R-squared values for each smoothing technique, which provides an indication of how well the technique is fitting the data.
Higher R-squared values indicate a better fit. By adjusting the input parameters for each smoothing technique, the user can compare the effectiveness of different techniques in removing noise from the input data.
Usage
You can use it to find the best fitting smoothing method for the timeframe you usually use.
Just apply it on your preferred timeframe and look for the highlighted table cell.
Conclusion
It seems like the T3 works best on timeframes under 4H.
There's where I am active, so I will use this one more in the future.
Thank you for checking this out. Enjoy your day and leave me a like or comment. 🧙♂️
---
Credits to:
▪@loxx – T3
▪@balipour – Super Smoother
▪ChatGPT – Wrote 80 % of this article and helped with the research
VHF Adaptive Linear Regression KAMAIntroduction
Heyo, in this indicator I decided to add VHF adaptivness, linear regression and smoothing to a KAMA in order to squeeze all out of it.
KAMA:
Developed by Perry Kaufman, Kaufman's Adaptive Moving Average (KAMA) is a moving average designed to account for market noise or volatility. KAMA will closely follow prices when the price swings are relatively small and the noise is low. KAMA will adjust when the price swings widen and follow prices from a greater distance. This trend-following indicator can be used to identify the overall trend, time turning points and filter price movements.
VHF:
Vertical Horizontal Filter (VHF) was created by Adam White to identify trending and ranging markets. VHF measures the level of trend activity, similar to ADX DI. Vertical Horizontal Filter does not, itself, generate trading signals, but determines whether signals are taken from trend or momentum indicators. Using this trend information, one is then able to derive an average cycle length.
Linear Regression Curve:
A line that best fits the prices specified over a user-defined time period.
This is very good to eliminate bad crosses of KAMA and the pric.
Usage
You can use this indicator on every timeframe I think. I mostly tested it on 1 min, 5 min and 15 min.
Signals
Enter Long -> crossover(close, kama) and crossover(kama, kama )
Enter Short -> crossunder(close, kama) and crossunder(kama, kama )
Thanks for checking this out!
--
Credits to
▪️@cheatcountry – Hann Window Smoohing
▪️@loxx – VHF and T3
▪️@LucF – Gradient
Chandelier Exit ZLSMA StrategyIntroduction
Heyo guys, I recently checked out some eye-catching trading strategy videos on YT and found one to test.
This indicator is based on the video.
Usage
The recommended timeframe is 5 min.
Signals
Long Entry => L Label
Price crosses above ZLSMA and Chandelier Exit shows Buy
Long Exit => green circle
Price crosses below ZLSMA
Short Entry => S Label
Price crosses below ZLSMA and Chandelier Exit shows Sell
Short Exit => orange circle
Prices crosses above ZLSMA
Ty for checking this out. Enjoy!
--
Credits to
@netweaver2011 - ZLSMA
@everget – Chandelier Exit
Adaptive Fisherized KSTIntroduction
Heyo guys, here is a new adaptive fisherized indicator of me.
I applied Inverse Fisher Transform, Ehlers dominant cycle analysis,
smoothing and divergence analysis on the Know Sure Thing (KST) indicator.
Moreover, the indicator doesn't repaint.
Usage
I didn't backtest the indicator, but I recommend the 5–15 min timeframe.
It can be also used on other timeframs, but I have no experience with that.
The indicator has no special filter system, so you need to find an own combo in order to build a trading system.
A trend filter like KAMA or my Adaptive Fisherized Trend Intensity Index could fit well.
If you find a good combo, let me know it in the comments pls.
Signals
Zero Line
KST crossover 0 => Enter Long
KST crossunder 0 => Enter Short
Cross
KST crossover KST MA => Enter Long
KST crossunder KST MA => Enter Short
Cross Filtered
KST crossover KST MA and KST above 0 => Enter Long
KST crossunder KST MA and KST under 0 => Enter Short
KST crossunder 0 => Exit Long
KST crossover 0 => Exit Short
More to read: KST Explanation
Enjoy and let me know your opinion!
--
Credits to
- @tista
- @blackcat1402
- @DasanC
- @cheatcountry
Adaptive Fisherized CMFIntroduction
Heyo, here I made a normalized Chaikin Money Flow (CMF) indicator with Inverse Fisher Transform (IFT) and some smoothing techniques.
I had to normalize the indicator in order to fit it to the IFT range (-1 -> 1).
Moreover, the good old adaptive mode is also included in this indicator. It uses Ehlers superb dominant cycle techniques.
It also has divergence detection, several options for individualisation and doesn't repaint.
Usage
www.investopedia.com
Signals
CMF above 0 => bullish market
CMF below 0 => bearish market
(You can also use the inner bands instead of the zero line, to make these signals more precise)
Bullish regular/hidden divergence => long
Bearish regular/hidden divergence => short
Enjoy guys!
PS: I really would like to hear some feedback of you.
Nadaraya-Watson: Envelope (Non-Repainting)Due to popular request, this is an envelope implementation of my non-repainting Nadaraya-Watson indicator using the Rational Quadratic Kernel. For more information on this implementation, please refer to the original indicator located here:
What is an Envelope?
In technical analysis, an "envelope" typically refers to a pair of upper and lower bounds that surrounds price action to help characterize extreme overbought and oversold conditions. Envelopes are often derived from a simple moving average (SMA) and are placed at a predefined distance above and below the SMA from which they were generated. However, envelopes do not necessarily need to be derived from a moving average; they can be derived from any estimator, including a kernel estimator such as Nadaraya-Watson.
How to use this indicator?
Overall, this indicator offers a high degree of flexibility, and the location of the envelope's bands can be adjusted by (1) tweaking the parameters for the Rational Quadratic Kernel and (2) adjusting the lookback window for the custom ATR calculation. In a trending market, it is often helpful to use the Nadaraya-Watson estimate line as a floating SR and/or reversal zone. In a ranging market, it is often more convenient to use the two Upper Bands and two Lower Bands as reversal zones.
How are the Upper and Lower bounds calculated?
In this indicator, the Rational Quadratic (RQ) Kernel estimates the price value at each bar in a user-defined lookback window. From this estimation, the upper and lower bounds of the envelope are calculated based on a custom ATR calculated from the kernel estimations for the high, low, and close series, respectively. These calculations are then scaled against a user-defined multiplier, which can be used to further customize the Upper and Lower bounds for a given chart.
How to use Kernel Estimations like this for other indicators?
Kernel Functions are highly underrated, and when calibrated correctly, they have the potential to provide more value than any mundane moving average. For those interested in using non-repainting Kernel Estimations for technical analysis, I have written a Kernel Functions library that makes it easy to access various well-known kernel functions quickly. The Rational Quadratic Kernel is used in this implementation, but one can conveniently swap out other kernels from the library by modifying only a single line of code. For more details and usage examples, please refer to the Kernel Functions library located here:
Adaptive Fisherized Stochastic Center of GravityIntroduction
I modified the script "Fisher Stochastic Center of Gravity" of @DasanC for this indicator.
I added inverse Fisher transform, cycle period adaptiveness mode (Ehlers) and smoothing to it.
Moreover, I added buy and sell and beautified some stuff.
Lastly, it is also non-repainting!
Usage
This indicator can be used like a normal stochastic, but I don't recommend divergence analysis on it.
That fisherization stuff seems to make the graphs unuseable for that because it tries.
It works well on every timeframe I would say, but lower timeframes are recommended, because of the fast nature of stochastic.
Usually it does a good job on entry confirmation for reversals and trend continuation trades.
Recommended indicator to combine with this indicator is RSI cyclic smoothed v2 .
This is the best RSI version I know. In trending market it is recommended to look more on the inner bands and in flat market it is recommended to look more on the outer bands.
When RSI shows oversold and this indicator shows a crossover of the Center of Gravity plot through the bottom line -> Long entry is confirmed
When RSI shows overbought and this indicator shows a crossunder of the Center of Gravity plot through the top line -> Short entry is confirmed
Settings
The adaptive mode is enabled by default to give you straight the whole indicator experience.
The default settings are optimized, but should be changed depending on the market.
An example:
Market has a low volatility and a high momentum -> I want a slower/higher length to catch the slower new highs and lows.
Market has higher volatility and a low momentum, -> I want a faster/lower length to catch the faster new highs and lows
Signals
Crossover
Buy -> cog crossover signalLine
Sell -> cog crossunder signalLine
Overbought/Oversold Crossover
Buy -> cog crossover lowerBand
Sell -> cog crossunder lowerBand
I use this indicator a lot, because I don't know a better stochastic on this community here.
@DasanC did an awesome work with his version I used as base for this script.
Enjoy this indicator and let the profit roll! 🔥
Candlestick OB FinderIntroduction
Hello, this here is a non-repainting candlestick indicator which is able to detect OB looking candlestick formations.
Usage
It can be used to confirm entries, but be aware that it produces a lot of false signals.
Somehow the swings tend to reverse at these points.
I recommend the 10–15 minutes timeframe.
I hope you enjoy this small indicator. :)
Fisherized CCIIntroduction
This here is a non-repainting indicator where I use inverse Fisher transformation and smoothing on the well-known CCI (Commdity Channel Index) momentum indicator.
"The Inverse Fisher Transform" describes the calculation and use of the inverse Fisher transform by Dr . Ehlers in 2004. The transform is applied to any indicator with a known probability distribution function. It enables to transform an indicator signal into the range between +1 and -1. This can help to eliminate the noise of an indicator.
The CCI is an momentum indicator which describes the distance of the price to the average price.
For smoothing I used the Hann Window and NET (Noise Elimination Technique) methods.
Additional Features
Divergence Analysis
Trend-adaptive Histogram
Timeframe selection
Usage
It is usually used to spot potential trend reverals or mean-reversion (against the trend) trades on lower timeframes. IMO it can be even used to spot trend-following trades. It always depends on which settings you have, which timeframe do you use and which indicators you combine with it.
The suggested timeframe for this indicator is 15 min (with the length setting on 50).
The histogram with adaptive mode enabled could be used as filter applied on the buy and sell signals.
The divergence analysis can help to spot additional entries/exits or confirm the buy and sell signals.
Always try to find the best settings! This indicators has a lot of customization options you should take advantage of.
Signals
The indicator uses the following logic to generate the buy and sell signals:
Normal
Buy -> When CCI and MA go above the top band (usually +100) and cross
Sell -> When CCI and MA go below the the bottom band (usually -100) and cross
Fisherized
Buy -> When CCI and MA go above the the zero line and cross
Sell -> When CCI and MA go below the the zero line and cross
Have fun with the indicator! I am open for feedback and questions. :)
Multiple Non-Anchored VWAPA lot of VWAP scripts are anchored and only allow single VWAP additions. This script allows up to 5 simultaneous VWAPs, for example monthly, quarterly, yearly, 3 years, etc. Can also be used on smaller timeframes. The non-anchored part of the script allows it to be constantly rolling, with no resets.
I do not endorse this script, it was created at my request :)
Bjorgum MTF MAScope:
Up to 3 MA's can be applied at the users discretion
Choose between 10 different average types including favorites from the Bjorgum series from HEMA to Reversal T3's
Each MA can be independently set
Go Multi-timeframe! Any MA can be set to any timeframe of reference you choose (ex. using 3 different timeframes of higher resolution to your chart reference to establish a multi-time frame trend)
RSI HEATMAP. Use the bar color or the MA color selection toggle to set your color to reference RSI on a gradient. This helps to establish clear visual reference to momentum on top of trend analysis
Assigning RSI bar color to an MA of a higher time frame can allow you to see visual reference of momentum of the greater trend that may be at play.
Example: trying to get short on a 15min while your 1hr and 4hr RSI Heatmap burns deep in oversold.
RSI color can be assigned to the bar color, the MA (1,2 or 3), or both. Alternatively, bar color can be assigned to a more simple rising/ falling MA color and price above/ below the MA for bar color.
ALL MTF FUNCTIONS ARE NON_REPAINTING.
The Idea
The original inspiration behind the script came from an observation of a constant struggle of Pinecoders of both youth or experience to find accurate multi-timeframe indicators that do not repaint, and appear as should on historical bars, while performing reliably in real time. I encourage you to scroll the Pinecoders FAQ on a recent piece explaining the difficulties and caveats of different approaches, but I would like to reference the elimination of the historical bar offset for THIS purpose. MA's are based on closing prices, that is to say they are confirmed and will not change once the bar has closed. There is no need to offset these for historical reference. The purpose of the historical offset is best exemplified, for example, with an intraday strategy involving daily breakouts. Let's entertain going long on a break to a new daily high. We would not know that in real time so we need to reference the previous bars close for BACKTESTING purposes, otherwise we get "lookahead bias". There is no shortage of strategies unintentionally employing this bias out there (I'm sure you have come across them with their unrealistic results).
There is no worry of repainting with the MTF security function included within this script, nor will it offset for something involving lookahead bias. I encourage those that are playing with the code or perhaps writing strategies of their own to borrow the functions within. There is also a function that will return the 10 MA variable selection - yours to keep.
With all that in mind, I wanted a practical script that is easily deployable in everyday trading for the average trader that gives the user a firm grip on their trading steering wheel equipped with the feel of the road. Incorporating several MA's of differing times with the RSI heatmap gives a good visual reference and feel to your trading environment, while offering a level of customization that will fit an individuals personal trading style. The RSI heatmap gradient is per percentage between 30 and 70 and your 2 colors - anything outside of those levels gives you the vibrant bias color
Below I walk through 2 examples of live trades scenarios I made using the mindset the script offers.
The Trade
LONG IZEA
Timeframe: 4hr chart
- 3 Tilson MA's of varying length are deployed at varying intraday time frames
- A bullish pattern in an uptrend offers a possible trade allowing entry from a low risk point from the pattern low
- See the chart for notes and observations using the script
- Notice how the heatmap brightens up as price extends far away from the averages - your risk has elevated for a new position
- Notice the heatmap cool off while price action consolidates sideways
The Trade
SHORT BTCUSDT
Timeframe: 4hr chart
- 3 EMAs are employed - same length (50), with 3 successive timeframe resolutions
- A downtrend is formed with a sharp move to stack the EMAs into layers
- A pull back opportunity presents itself in bearish consolidation
- Notice a Doji star at resistance establishing a swing high as RSI cools off into the EMA dynamic resistance for entry
- An '"equal legs" measured move can be used for a trade target with a stop out above the swing high.
- Again, take note of distance from EMA's, the heatmap in combination with trend development surrounding the MA's
These were just two ideas to show you an example of how to implement some strategy into your trading and to get some interesting use from the indicator. Hope you enjoyed the read and happy trading.
Hide extended hours/non-intraday barsEspecially for future users, such as ES/NQ/RTY/YM, etc., this script can hide the extended hours/non-intraday bars and leave the intraday bars only.
With this script , you can find the intraday support/resistance quite easily!
Example, if you are a ES investor, you can easily find the intraday support/resistance level ,which is almost equal to SPY, with this script, and no need to check SPY separately again , saving your time a lot.
Note: Please couple this script with American Bars. If you use candle charts, the upper/lower pins of the candle can't be hidden with the bars together, which is restricted by the code editor itself...
Backtesting on Non-Standard Charts: Caution! - PineCoders FAQMuch confusion exists in the TradingView community about backtesting on non-standard charts. This script tries to shed some light on the subject in the hope that traders make better use of those chart types.
Non-standard charts are:
Heikin Ashi (HA)
Renko
Kagi
Point & Figure
Range
These chart types are called non-standard because they all transform market prices into synthetic views of price action. Some focus on price movement and disregard time. Others like HA use the same division of bars into fixed time intervals but calculate artificial open, high, low and close (OHLC) values.
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 algorithmically. 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.
The delta between the chart’s price when an order is issued (which is assumed to be the expected price) and the price at which that order is filled is called slippage . When working from normal chart types, slippage can be caused by one or more of the following conditions:
• Time delay between order submission and execution. During this delay the market may move normally or be subject to large orders from other traders that will cause large moves of the bid/ask levels.
• Lack of bids for a market sell or lack of asks for a market buy at the current price level.
• Spread taken by middlemen in the order execution process.
• Any other event that changes the expected fill price.
When a market order is submitted, matching engines attempt to fill at the best possible price at the exchange. TradingView strategies usually fill market orders at the opening price of the next candle. A non-standard chart type can produce misleading results because the open of the next candle may or may not correspond to the real market price at that time. This creates artificial and often beneficial slippage that would not exist on standard charts.
Consider an HA chart. The open for each candle is the average of the previous HA bar’s open and close prices. The open of the HA candle is a synthetic value, but the real market open at the time the new HA candle begins on the chart is the unrelated, regular open at the chart interval. The HA open will often be lower on long entries and higher on short entries, resulting in unrealistically advantageous fills.
Another example is a Renko chart. A Renko chart is a type of chart that only measures price movement. The purpose of a Renko chart is to cluster price action into regular intervals, which consequently removes the time element. Because Trading View does not provide tick data as a price source, it relies on chart interval close values to construct Renko bricks. As a consequence, a new brick is constructed only when the interval close penetrates one or more brick thresholds. When a new brick starts on the chart, it is because the previous interval’s close was above or below the next brick threshold. The open price of the next brick will likely not represent the current price at the time this new brick begins, so correctly simulating an order is impossible.
Some traders have argued with us that backtesting and trading off HA charts and other non-standard charts is useful, and so we have written this script to show traders what happens when order fills from backtesting on non-standard charts are compared to real-world fills at market prices.
Let’s review how TV backtesting works. TV backtesting uses a broker emulator to execute orders. When an order is executed by the broker emulator on historical bars, the price used for the fill is either the close of the order’s submission bar or, more often, the open of the next. The broker emulator only has access to the chart’s prices, and so it uses those prices to fill orders. When backtesting is run on a non-standard chart type, orders are filled at non-standard prices, and so backtesting results are non-standard—i.e., as unrealistic as the prices appearing on non-standard charts. This is not a bug; where else is the broker emulator going to fetch prices than from the chart?
This script is a strategy that you can run on either standard or non-standard chart types. It is meant to help traders understand the differences between backtests run on both types of charts. For every backtest, a label at the end of the chart shows two global net profit results for the strategy:
• The net profits (in currency) calculated by TV backtesting with orders filled at the chart’s prices.
• The net profits (in currency) calculated from the same orders, but filled at market prices (fetched through security() calls from the underlying real market prices) instead of the chart’s prices.
If you run the script on a non-standard chart, the top result in the label will be the result you would normally get from the TV backtesting results window. The bottom result will show you a more realistic result because it is calculated from real market fills.
If you run the script on a normal chart type (bars, candles, hollow candles, line, area or baseline) you will see the same result for both net profit numbers since both are run on the same real market prices. You will sometimes see slight discrepancies due to occasional differences between chart prices and the corresponding information fetched through security() calls.
Features
• Results shown in the Data Window (third icon from the top right of your chart) are:
— Cumulative results
— For each order execution bar on the chart, the chart and market previous and current fills, and the trade results calculated from both chart and market fills.
• You can choose between 2 different strategies, both elementary.
• You can use HA prices for the calculations determining entry/exit conditions. You can use this to see how a strategy calculated from HA values can run on a normal chart. You will notice that such strategies will not produce the same results as the real market results generated from HA charts. This is due to the different environment backtesting is running on where for example, position sizes for entries on the same bar will be calculated differently because HA and standard chart close prices differ.
• You can choose repainting/non-repainting signals.
• You can show MAs, entry/exit markers and market fill levels.
• You can show candles built from the underlying market prices.
• You can color the background for occurrences where an order is filled at a different real market price than the chart’s price.
Notes
• On some non-standard chart types you will not obtain any results. This is sometimes due to how certain types of non-standard types work, and sometimes because the script will not emit orders if no underlying market information is detected.
• The script illustrates how those who want to use HA values to calculate conditions can do so from a standard chart. They will then be getting orders emitted on HA conditions but filled at more realistic prices because their strategy can run on a standard chart.
• On some non-standard chart types you will see market results surpass chart results. While this may seem interesting, our way of looking at it is that it points to how unreliable non-standard chart backtesting is, and why it should be avoided.
• In order not to extend an already long description, we do not discuss the particulars of executing orders on the realtime bar when using non-standard charts. Unless you understand the minute details of what’s going on in the realtime bar on a particular non-standard chart type, we recommend staying away from this.
• Some traders ask us: Why does TradingView allow backtesting on non-standard chart types if it produces unrealistic results? That’s somewhat like asking a hammer manufacturer why it makes hammers if hammers can hurt you. We believe it’s a trader’s responsibility to understand the tools he is using.
Takeaways
• Non-standard charts are not bad per se, but they can be badly used.
• TV backtesting on non-standard charts is not broken and doesn’t require fixing. Traders asking for a fix are in dire need of learning more about trading. We recommend they stop trading until they understand why.
• Stay away from—even better, report—any vendor presenting you with strategies running on non-standard charts and implying they are showing reliable results.
• If you don’t understand everything we discussed, don’t use non-standard charts at all.
• Study carefully how non-standard charts are built and the inevitable compromises used in calculating them so you can understand their limitations.
Thanks to @allanster and @mortdiggiddy for their help in editing this description.
Look first. Then leap.
Zero Phase Filtering [Repaint] - ExperimentalImportant !
The indicator is for experimental purpose only, it must not be used as a decisional tool but only as a visual one (like Zig-Zag, Fractal etc). The information this indicator display is uncertain and subject to drastic changes over time. If you have further question feel free to pm me.
Introduction
Most of the filters you will find are causal, this mean that they depend on present and past input values, this explain the lag they produce. Non causal filters however will use future input values. A well know way to get a zero-phase filter is by using the forward backward method, but this is not possible in pinescript as i recall. So we have to use some kind of function that will display future values, this is possible using the security function in version 2 or the one in version 3 using barmerge.lookahead_on .
The Use Of A Repainting Indicator
Its always better to filter data in order to have a clearer view of what is happening, this can be useful when doing some forecasting or doing less formal kind of analysis. However since it repaint you cant use it as a signal provider or use signals of other indicators using this filter as source.
For example if you want to forecast a smooth indicator, the forecast of this indicator under normal circumstances could still have lag associated with it, so you would have to react before your forecast, this wont happen if you apply this filter as your indicator source.
The Filter
We smooth with a simple moving average the price provided by the security function twice, length control the smoothing level. Since security depend on the time frame you are in you must select your time frame in the indicator parameter selection window.
Filtering using 45 minutes time frame close price in a 5 minutes chart, we fix this by selecting our time frame.
Consider the fact that the input of the indicator is just periodic price, so sometimes the lag can sometimes be less or more than 0 and the estimation not centered.
The indicator can work on time frames up to 1h, after that the filter have some lag, i tried fixing this and i ended up having data errors.
Applying our filter as source for the rsi oscillator.
Conclusion
It is possible to have a kind of zero-phase filters, but it would be better if pinescript could support backward indexing thus making us able to do forward backward filtering.
Since noise can affect our analysis, applying smoothing without having to use offset in plot can be considered useful.
B3 ALMA PendulumB3 Pendulums, quick little indicators that do change print inside the current bar, so beware. It is good for anticipation, but it is important to make sure the current and next bars follow through.
Ever wanted an indicator that really points out the micro term action in the form of a pendulum swing? This my attempt to show the market ups and downs in the smallest amount of lag possible. This indicator is designed to bounce back and forth from 100 to -100 as it shows you the price's relationship to ALMA. Really its just a simple deviance from mean study made to amplify the quick ups and downs, and kind of the neatest on Heikin Ashi setups. It looks like Arabic language at first glance, lol.
This should be easy to template out to your own MA's. ~I hope you are enjoying the B3 scripts, that is now 9 open source shares and a couple protected ones. I still plan on a few more give-a-ways, as I prepare some of the algorithmic things I do for subscription. Feel free to comment about things you would like to see! ~B3
Commitments of Traders(COT) Major's noncom net (beta) By Lowphata charted commitments of traders report
of most majors on one chart.
EUR=red
GBP=blue
CHF=white
CAD=dark green
USD bright green
JPY=yellow
AUD=brown