Simple
Hybrid Triple Exponential Smoothing🙏🏻 TV, I present you HTES aka Hybrid Triple Exponential Smoothing, designed by Holt & Winters in the US, assembled by me in Saint P. I apply exponential smoothing individually to the data itself, then to residuals from the fitted values, and lastly to one-point forecast (OPF) errors, hence 'hybrid'. At the same time, the method is a closed-form solution and purely online, no need to make any recalculations & optimize anything, so the method is O(1).
^^ historical OPFs and one-point forecasting interval plotted instead of fitted values and prediction interval
Before the How-to, first let me tell you some non-obvious things about Triple Exponential smoothing (and about Exponential Smoothing in general) that not many catch. Expo smoothing seems very straightforward and obvious, but if you look deeper...
1) The whole point of exponential smoothing is its incremental/online nature, and its O(1) algorithm complexity, making it dope for high-frequency streaming data that is also univariate and has no weights. Consequently:
- Any hybrid models that involve expo smoothing and any type of ML models like gradient boosting applied to residuals rarely make much sense business-wise: if you have resources to boost the residuals, you prolly have resources to use something instead of expo smoothing;
- It also concerns the fashion of using optimizers to pick smoothing parameters; honestly, if you use this approach, you have to retrain on each datapoint, which is crazy in a streaming context. If you're not in a streaming context, why expo smoothing? What makes more sense is either picking smoothing parameters once, guided by exogenous info, or using dynamic ones calculated in a minimalistic and elegant way (more on that in further drops).
2) No matter how 'right' you choose the smoothing parameters, all the resulting components (level, trend, seasonal) are not pure; each of them contains a bit of info from the other components, this is just how non-sequential expo smoothing works. You gotta know this if you wanna use expo smoothing to decompose your time series into separate components. The only pure component there, lol, is the residuals;
3) Given what I've just said, treating the level (that does contain trend and seasonal components partially) as the resulting fit is a mistake. The resulting fit is level (l) + trend (b) + seasonal (s). And from this fit, you calculate residuals;
4) The residuals component is not some kind of bad thing; it is simply the component that contains info you consciously decide not to include in your model for whatever reason;
5) Forecasting Errors and Residuals from fitted values are 2 different things. The former are deltas between the forecasts you've made and actual values you've observed, the latter are simply differences between actual datapoints and in-sample fitted values;
6) Residuals are used for in-sample prediction intervals, errors for out-of-sample forecasting intervals;
7) Choosing between single, double, or triple expo smoothing should not be based exclusively on the nature of your data, but on what you need to do as well. For example:
- If you have trending seasonal data and you wanna do forecasting exclusively within the expo smoothing framework, then yes, you need Triple Exponential Smoothing;
- If you wanna use prediction intervals for generating trend-trading signals and you disregard seasonality, then you need single (simple) expo smoothing, even on trending data. Otherwise, the trend component will be included in your model's fitted values → prediction intervals.
8) Kind of not non-obvious, but when you put one smoothing parameter to zero, you basically disregard this component. E.g., in triple expo smoothing, when you put gamma and beta to zero, you basically end up with single exponential smoothing.
^^ data smoothing, beta and gamma zeroed out, forecasting steps = 0
About the implementation
* I use a simple power transform that results in a log transform with lambda = 0 instead of the mainstream-used transformers (if you put lambda on 2 in Box-Cox, you won't get a power of 2 transform)
* Separate set of smoothing parameters for data, residuals, and errors smoothing
* Separate band multipliers for residuals and errors
* Both typical error and typical residuals get multiplied by math.sqrt(math.pi / 2) in order to approach standard deviation so you can ~use Z values and get more or less corresponding probabilities
* In script settings → style, you can switch on/off plotting of many things that get calculated internally:
- You can visualize separate components (just remember they are not pure);
- You can switch off fit and switch on OPF plotting;
- You can plot residuals and their exponentially smoothed typical value to pick the smoothing parameters for both data and residuals;
- Or you might plot errors and play with data smoothing parameters to minimize them (consult SAE aka Sum of Absolute Errors plot);
^^ nuff said
More ideas on how to use the thing
1) Use Double Exponential Smoothing (data gamma = 0) to detrend your time series for further processing (Fourier likes at least weakly stationary data);
2) Put single expo smoothing on your strategy/subaccount equity chart (data alpha = data beta = 0), set prediction interval deviation multiplier to 1, run your strat live on simulator, start executing on real market when equity on simulator hits upper deviation (prediction interval), stop trading if equity hits lower deviation on simulator. Basically, let the strat always run on simulator, but send real orders to a real market when the strat is successful on your simulator;
3) Set up the model to minimize one-point forecasting errors, put error forecasting steps to 1, now you're doing nowcasting;
4) Forecast noisy trending sine waves for fun.
^^ nuff said 2
All Good TV ∞
Double Ribbon [ChartPrime]The Double Ribbon - ChartPrime indicator is a powerful tool that combines two sets of Simple Moving Averages (SMAs) into a visually intuitive ribbon, which helps traders assess market trends and momentum. This indicator features two distinct ribbons: one with a fixed length but changing offset (displayed in gray) and another with varying lengths (displayed in colors). The relationship between these ribbons forms the basis of a trend score, which is visualized as an oscillator. This comprehensive approach provides traders with a clear view of market direction and strength.
◆ KEY FEATURES
Dual Ribbon Visualization : Displays two sets of 11 SMAs—one in a neutral gray color with a fixed length but varying offset, and another in vibrant colors with lengths that increase incrementally.
Trend Score Calculation : The trend score is derived from comparing each SMA in the colored ribbon with its corresponding SMA in the gray ribbon. If a colored SMA is above its gray counterpart, a positive score is added; if below, a negative score is assigned.
// Loop to calculate SMAs and update the score based on their relationships
for i = 0 to length
// Calculate SMA with increasing lengths
sma = ta.sma(src, len + 1 + i)
// Update score based on comparison of primary SMA with current SMA
if sma1 < sma
score += 1
else
score -= 1
// Store calculated SMAs in the arrays
sma_array.push(sma)
sma_array1.push(sma1 )
Dynamic Trend Analysis : The score oscillator provides a dynamic analysis of the trend, allowing traders to quickly gauge market conditions and potential reversals.
Customizable Ribbon Display : Users can toggle the display of the ribbon for a cleaner chart view, focusing solely on the trend score if desired.
◆ USAGE
Trend Confirmation : Use the position and color of the ribbon to confirm the current market trend. When the colored ribbon consistently stays above the gray ribbon, it indicates a strong uptrend, and vice versa for a downtrend.
Momentum Assessment : The score oscillator provides insight into the strength of the current trend. Higher scores suggest stronger trends, while lower scores may indicate weakening momentum or a potential reversal.
Strategic Entry/Exit Points : Consider using crossovers between the ribbons and changes in the score oscillator to identify potential entry or exit points in trades.
⯁ USER INPUTS
Length : Sets the base length for the primary SMAs in the ribbons.
Source : Determines the price data used for calculating the SMAs (e.g., close, open).
Ribbon Display Toggle : Allows users to show or hide the ribbon on the chart, focusing on either the ribbon, the trend score, or both.
⯁ CONCLUSION
The Double Ribbon indicator offers traders a comprehensive tool for analyzing market trends and momentum. By combining two ribbons with varying SMA lengths and offsets, it provides a clear visual representation of market conditions. The trend score oscillator enhances this analysis by quantifying trend strength, making it easier for traders to identify potential trading opportunities and manage risk effectively.
ATR Percentage ValuesThis indicator is created to give you the daily ATR 2% and 10% values for any product that you are looking at. The way the indicator is designed is to only show the most recent 2 and 10 percent values on any chart and will not show you any other number. If you are hovering over price that occurred in the past it will show zeros on the values. To get the right values, take your mouse off of the chart and it will show you the values.
The way this indicator is coded will give you the daily ATR numbers no matter what chart timeframe you are currently looking at. The idea is to save time and make sure you do not make a mistake getting the wrong value.
*** To make this show up on the status line, click on the settings, click on the style box and check the box "VALUES IN STATUS LINE" ****
Average Range LinesThis Average Range Lines indicator identifies high and low price levels based on a chosen time period (day, week, month, etc.) and then uses a simple moving average over the length of the lookback period chosen to project support and resistance levels, otherwise referred to as average range. The calculation of these levels are slightly different than Average True Range and I have found this to be more accurate for intraday price bounces.
Lines are plotted and labeled on the chart based on the following methodology:
+3.0: 3x the average high over the chosen timeframe and lookback period.
+2.5: 2.5x the average high over the chosen timeframe and lookback period.
+2.0: 2x the average high over the chosen timeframe and lookback period.
+1.5: 1.5x the average high over the chosen timeframe and lookback period.
+1.0: The average high over the chosen timeframe and lookback period.
+0.5: One-half the average high over the chosen timeframe and lookback period.
Open: Opening price for the chosen time period.
-0.5: One-half the average low over the chosen timeframe and lookback period.
-1.0: The average low over the chosen timeframe and lookback period.
-1.5: 1.5x the average low over the chosen timeframe and lookback period.
-2.0: 2x the average low over the chosen timeframe and lookback period.
-2.5: 2.5x the average low over the chosen timeframe and lookback period.
-3.0: 3x the average low over the chosen timeframe and lookback period.
Look for price to find support or resistance at these levels for either entries or to take profit. When price crosses the +/- 2.0 or beyond, the likelihood of a reversal is very high, especially if set to weekly and monthly levels.
This indicator can be used/viewed on any timeframe. For intraday trading and viewing on a 15 minute or less timeframe, I recommend using the 4 hour, 1 day, and/or 1 week levels. For swing trading and viewing on a 30 minute or higher timeframe, I recommend using the 1 week, 1 month, or longer timeframes. I don’t believe this would be useful on a 1 hour or less timeframe, but let me know if the comments if you find otherwise.
Based on my testing, recommended lookback periods by timeframe include:
Timeframe: 4 hour; Lookback period: 60 (recommend viewing on a 5 minute or less timeframe)
Timeframe: 1 day; Lookback period: 10 (also check out 25 if your chart doesn’t show good support/resistance at 10 days lookback – I have found 25 to be useful on charts like SPX)
Timeframe: 1 week; Lookback period: 14
Timeframe: 1 month; Lookback period: 10
The line style and colors are all editable. You can apply a global coloring scheme in the event you want to add this indicator to your chart multiple times with different time frames like I do for the weekly and monthly.
I appreciate your comments/feedback on this indicator to improve. Also let me know if you find this useful, and what settings/ticker you find it works best with!
Also check out my profile for more indicators!
10 MAs Alpha Indicator by MontyThis indicator is a part of the script I coded earlier this month.
The name is to surprise one of our discord member.
I will publish that indicator in a few days as well, but publishing this as a gesture of giving back to the community.
Indicator has:
10 Moving Averages
Adjustable Color, Opacity and Size etc
Shows Labels for each of the MA.
Can be shifted between EMA or SMA
Can be fixed to show a specific TF MA on current Timeframe.
Opening Range with Infinite Price TargetsOpening Range with Infinite Price Targets is an ORB indicator that automatically generates price targets into infinity based on a user-defined % of range.
This indicator includes many nice-to-have features missing from other indicators. Such as:
Price Target Labels with Price tooltip, want to know exactly what price pt3 is at? Hover over it and see.
Custom Defined Range time, Set your Range Start and end time to whatever you need, Doesn't have to be pinned to opening range!. Note: Time is in chart time.
Historical View (Default off), Tired of your chart looking messy with a ton of lines from historical data? No problem! You can choose to view or not view historical data.
Alerts for Range Breaks, First Range Breaks, and Discovery Price Target hits. As well as Exported Values for Range High, Low, and Mean to set your own alerts from custom sources.
Custom Price Targets, set your price targets to a % of the range based on your own strategy.
Last but not Least, Infinitely Generating Price Targets. They just keep building. New Targets will be generated when the price closes above/below the current farthest target.
Enjoy!
MACD strategy + Trailstop indicatorWelcome traveler !
Here is my first indicator I made after 3 days of hardlearning pine code (beginner in coding).
I hope it will please you, if you have any suggestion to enhance this indicator, do not hesitate to give me your thoughts in the comments section or by Private message on trading View !
How does it works ?
It's a simple MACD strategy as describe here :
Uses of EMA 200 as a trend confirmer,
For sells :
When above Zero line (MACD) and under EMA200, we go on sell (background color is red)
For buys:
When under Zero line (MACD) and above EMA 200, we go on Buy (back ground color is green)
FILTERS !
I haded one filter to reduce noise on the indicator :
Signals aren't taken if one of the 14 last candles closed on the other side of the EMA 14.
What are the green and red lines ?
The green line is equivalent of a potential stop loss as a buyer side, same for the red one on seller side !
To make the space with the price bigger, please use "ATR multiplier" in the input options of the indicator while on your chart !
Is it timeframe specific ?
Hell no it is not timeframe specific ! You can try to use it on every timeframe !
As usual, I like to remind you that the best way to test an indicator is to go backtest it or to paper trade before using it on real market conditions !
If you find an idea of filter for a specific timeframe, do not hesitate to contact me ! I'll try to do my best to enhance this indicator as the time goes !
Is there repainting ?
There is no repainting on confirmation !
There's only a movement that I don't know how to ignore on the current open candle for the trail stop indicator I built, it should not be a problem if you place alerts to automatise your trading on the close of the candle, and not the high or low !
If you know how to resolve this problem with my code, I would be glad to get your tips to enhance the script ! :)
Example of the indicator in market (backtest, as said, no repaint on confirmation) :
Simple LevelsSimple Level provides a (you guessed it) simple user to user level sharing experience, with less boxes, less formatting, and less hassle.
Simply insert your levels into the input box, separated by commas. That's it.
Example: 1,2,3,4,5
The Simple Levels indicator will automatically color your lines based on their position to the current close price.
If the level is crossed, the level line will change color.
This indicator is intended for those who just want to skip filling out boxes or typing in a tricky format, and cut to the chase.
There are additional, nice-to-have settings as well for the "more" technically inclined; however, nothing too complicated.
Enjoy!
SMA RegimeProvides a color coded indicator based upon both the slope of a moving average of choice, and the asset's position in relation to that moving average. If the specified moving average is downward sloping and the asset closes below the moving average the indicator will be red. If the specified moving average is upward sloping and the asset closes above the moving average the indicator will be green. Any other combination of these two factors will color the indicator yellow indicating indecision.
Aggregated Moving AveragesUsers can display moving averages from higher time frame charts and display them on their current chart. This script supports up to 4 moving averages aggregated from a selected time frame. Each plot can be toggled if the user does not wish to have all 4 plots displayed.
Inputs allow user to edit:
Moving average length
Average type
Color
Timeframe input allows user to select which timeframe the moving averages are calculated from.
If you wish to have multiple timeframes across different moving averages, it is recommended you add a separate copies of the indicator for each timeframe you wish to display. Toggle visibility of which plots which you don't need.
TRADING MADE SIMPLEThis indicator shows market structure. The standard method of using Williams Highs and Lows as pivots, is something of an approximation.
What's original here is that we follow rules to confirm Local Highs and Local Lows, and strictly enforce that a Low can only follow a confirmed High and vice-versa.
-- Highs and Lows
To confirm a candle as a Local High, you need a later candle to Close below its Low. To confirm a Local Low, you need a Close above its High.
A Low can only follow a High (after it's been confirmed). You can't go e.g High, High, Low, Low, only High, Low, High, Low.
When price makes Higher Highs and Higher Lows, market structure is said to be bullish. When price makes Lower Lows and Lower Highs, it's bearish.
I've defined the in-between Highs and Lows as "Ranging", meaning, neutral. They could be trend continuation or reversal.
-- Bullish/Bearish Breaks
A Bullish break in market structure is when the Close of the current candle goes higher than the previous confirmed Local High.
A Bearish Break is when the Close of the current candle goes lower than the most recent confirmed Local Low.
I chose to use Close rather than High to reduce edge case weirdness. The breaking candle often ends up being a big one, thus the close of that candle can be a poor entry.
You can get live warnings by setting the alert to Options: Only Once, because during a candle, the current price is taken as the Close.
Breaks are like early warnings of a change in market bias, because you're not waiting for a High or Low to be formed and confirmed.
Buy The Dip / Sell The Rally
Buy The Dip is a label I gave to the first Higher Low in a bullish market structure. Sell The Rally is the first Lower High in a bearish market structure.
These *might* be good buying/selling opportunities, but you still need to do your own analysis to confirm that.
== USAGE ==
The point of knowing market structure is so you don't make bullish bets in a bearish market and vice versa -
or if you do at least you're aware that that's what you're doing, and hopefully have some overwhelmingly good reason to do so.
These are not signals to be traded on their own. You still need a trade thesis. Use with support & resistance and your other favourite indicators.
Works on any market on any timeframe. Be aware that market structure will be different on different timeframes.
IMPORTANT: If you're not seeing what you expect, check your settings and re-read this entire description carefully. Confirming Highs and Lows can get deceptively complex.
EMA Oscilator [Azzrael]Just one more simple and useless Oscilator based on EMA. I've used Standard Deviation of (close - ema) to show overheated zones.
CRC.i Golden Death CrossThis is a simple reproduction of a common indicator used for analyzing the current momentum trend.
Golden Cross => 50 day simple moving average (sma) crosses over the 200 sma
Death Cross => 50 day simple moving average (sma) crosses under the 200 sma
Forecasting used in this indicator is a simple moving average, considering the price sma with length of (sma period - future bar count).
More articles at
mirror.xyz
medium.com
34 EMA BandsThis is quite a simple script, just plotting a 34EMA on high's and low's of candles. Appears to work wonders though, so here it is.
There is some //'d code which I haven't finished working on, but it looks to be quite similar to Bollinger Bands, just using different math rather than standard deviations from the mean.
The bands itself is pretty self explanatory, price likes to use it as resistance when under it, it can trade inside it and it can use the upper EMA as support when in a strong upward trend.
Ehlers Simple Window Indicator [CC]The Simple Window Indicator was created by John Ehlers (Stocks and Commodities Sep 2021) and this is the last of the 4 new indicators that he published in the latest issue of Stocks & Commodities. Since these are all part of a series, the idea behind each indicator is the exact same. The only difference is of course the calculation for each indicator. This script is different mostly because it is extremely noisy in comparison so I had to smooth it twice to provide clear buy and sell signals. Window functions are used in digital signal processing to filter out noise and the end result is an oscillator that centers around the 0 line. The easy way to understand these indicators that I will be publishing and those are that when they are above 0, it usually means an uptrend and below 0 then a downtrend. For more immediate signals, I have included both normal and strong buy and sell signals so darker colors for strong signals and lighter colors for normal signals. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you would like me to publish!
Ehlers Simple Clip Indicator [CC]The Simple Clip Indicator was created by John Ehlers (Stocks and Commodities June 2021 pg 10) and this is obviously very similar to the previous indicator I published ( Ehlers Simple Deriv Indicator ) so I would recommend to try both out and see what you prefer. This is a new momentum indicator that is extremely responsive to price changes and when the indicator is above 0 then this means the stock is in a long term uptrend and when it is below 0 then it is in a long term downtrend. I have color coded the indicator line to show you both strong buy and sell signals and normal buy and sell signals. Dark colors are strong signals and of course green means a buy signal and red means a sell signal. I did change the original buy and sell signals that Ehlers included in his scripts because I didn't find that they worked very well so let me know what you think of my changes.
Let me know if there are any other indicators you would like to see me publish!
Ehlers Simple Deriv Indicator [CC]The Simple Deriv Indicator was created by John Ehlers (Stocks and Commodities June 2021 pg 10) and this is a heavily modified version of his original script that changes the buy and sell signals. I did testing with his original settings but they didn't seem to be very profitable for most stocks so I created my own system. This indicator does have a lag though so it is best used for trend confirmation imo. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you would like to see me publish!
Simple Bollinger Bands + 3 EMAWe know that the number of indicators that we can use is limited, that is why with this indicator the Bollinger Bands + 3 EMAs join and be able to use 4 indicators in 1.
Bollinger Bands (BB)
Bollinger Bands (BB) are a widely popular technical analysis instrument created by John Bollinger in the early 1980’s. Bollinger Bands consist of a band of three lines which are plotted in relation to security prices. The line in the middle is usually a Simple Moving Average (SMA) set to a period of 20 days (the type of trend line and period can be changed by the trader; however a 20 day moving average is by far the most popular). The SMA then serves as a base for the Upper and Lower Bands which are used as a way to measure volatility by observing the relationship between the Bands and price. Typically the Upper and Lower Bands are set to two standard deviations away from the SMA (The Middle Line); however the number of standard deviations can also be adjusted by the trader.
Exponential Moving Average (EMA)
Moving averages visualize the average price of a financial instrument over a specified period of time. However, there are a few different types of moving averages. They typically differ in the way that different data points are weighted or given significance. An Exponential Moving Average (EMA) is very similar to (and is a type of) a weighted moving average. The major difference with the EMA is that old data points never leave the average. To clarify, old data points retain a multiplier (albeit declining to almost nothing) even if they are outside of the selected data series length.
The 3 EMAs that the Script has, are configured as follows:
Fast EMA (purple) 10 periods.
Slow EMA (blue) 55 periods.
Big EMA (olive) 200 periods.
However, you can configure each one with the color and the number of periods you want.
There are other indicators in the Public Library that have similar functions to this Script, but they all do it in a more complex and less friendly way when configuring it, for this reason we wanted to keep this Script as simple as possible.
3SMA + Ichimoku 2leadlineThis indicator simultaneously displays two lines, which are the leading spans of the Ichimoku Kinko Hyo, and three simple moving averages.
To make it easier to distinguish between the simple moving average line and the line of the Ichimoku Kinko Hyo, the simple moving average line is set to level 2 thickness by default.
Also, the color of Reading Span 1 in the Ichimoku Kinko Hyo has been changed from green to lime to improve color visibility.
I (author of this indicator) use this indicator especially as a simple perspective on the cryptocurrency BTC / USD(USDT).
If this indicator is a problem, moderators don't know about tradingview beginners.
" Visibility " should be a high-priority item not only for indicators but also for graph requirements.
Visibility is one of the most important factors for investors who have to make instant decisions in one minute and one second.
The purpose of this indicator is to display two leading spans that are easily noticed in the Ichimoku cloud and three simple moving averages whose set values can be changed.
This is because chart analysis often uses a combination of a simple moving average of three periods and two lead spans of the Ichimoku cloud.
Also, in chart analysis, green is often displayed with the same thickness on both the moving average line and the Ichimoku cloud.
Therefore, if the moving average line and the Ichimoku cloud often use the same green color, the visibility will drop. Therefore, the green color of Ichimoku cloud was changed to lime color by default.
Tradingview beginners often refer only to the two lines of the leading span of Ichimoku Cloud. Therefore, we decided not to draw lines that are difficult to use.
Many Tradingview beginners don't know that you can change the thickness of the indicator .
Therefore, this indicator shows by DEFAULT the three commonly used simple moving averages that are thickened by one step at the same time.
Also, since the same green color is often used for the Ichimoku cloud and the moving average line, the green color of the preceding span of the Ichimoku cloud is changed to lime color by default.
The originality of this indicator is that it enhances " visibility " so that novice tradingview users will not be confused on the chart screen.
The lines other than the preceding span of the Ichimoku cloud are not displayed, and the moving average line is level 2 thick so that the user can easily see it.
This indicator not only combines a simple moving average and Ichimoku cloud, but also improves "visibility" by not incorporating lines that are difficult to see from the beginning and making it only the minimum display, making it easy for beginners to understand. The purpose is to do.
If any of the other TradingView indicators already meet the following, acknowledge that this indicator is not original.
・Display 3 simple moving averages at the same time
・For visibility, the thickness of the simple moving average line is set to level 2 from the beginning.
・A setting that does not dare to draw lines other than the lead span of Ichimoku cloud.
・Make the moving average line and the Ichimoku cloud line different colors and thicknesses from the beginning.
Exotic SMA Explorations Treasure TroveThis is my "Exotic SMA Explorations Treasure Trove" intended for educational purposes, yet these functions will also have utility in special applications with other algorithms. Firstly, the Pine built-in sma() is exceedingly more efficient computationally on TV servers than these functions will be. I just wanted to make that very crystal clear. My notes elaborate on this in the code blatantly.
Anyhow, the simple moving average(SMA) is one of the most common averaging filters used in a wide variety of algorithms. "Simply put," it's name says a lot about it. The purpose of this script, is to demonstrate variations of it's calculation in a multitude of exotic forms. In certain scenarios our algorithms may require a specific mathemagical touch that is pertinent to our intended goals. Like screwdrivers, we often need different types depending on the objective we are trying to attain. The SMA also serves as the most basic of finite impulse response(FIR) algorithms. For example, things like weighted moving averages can be constructed by using the foundational code of SMA.
One other intended demonstration of this script, is running multiple functions for comparison. I have had to use this from time to time for my own comparisons of performance. Also, imbedded into this code is a method to generically and recklessly in this case, adapt an algorithm. I will warn you, RSI was NEVER intended to adapt an algorithm. It only serves as a crude method to display the versatility of these different algorithms, whether it be a benefit or hinderance concerning dynamic adaptability.
Lastly, this script shows the versatility of TV's NEW additions input(group=) and input(inline=) upgrades in action. The "Immense Power of Pine" is always evolving and will continue to do so, I assure you of that. We can now categorize our input()s without using the input(type=input.bool) hackTrick. Although, that still will have it's enduring versatility, at least for myself.
NOTICE: You have absolute freedom to use this source code any way you see fit within your new Pine projects. You don't have to ask for my permission to reuse these functions in your published scripts, simply because I have better things to do than answer requests for the reuse of these functions. Sufficient accreditation regarding this script and compliance with "TV's House Rules" regarding code reuse, is as easy as copying the functions in their entirety as is. Fair enough? Good!
When available time provides itself, I will consider your inquiries, thoughts, and concepts presented below in the comments section, should you have any questions or comments regarding this indicator. When my indicators achieve more prevalent use by TV members, I may implement more ideas when they present themselves as worthy additions. Have a profitable future everyone!
Easy TrendThis signal is completely based on analysis and transformation of a single simple moving average. As with all signals and indicators, it should be combined with others.
This is how the signal is built:
1. First it takes the SMA of the closing price.
2. It then takes the ROC of that SMA using a length of 1.
3. It takes an 8-period SMA and also a 64-period SMA of that ROC.
4. These are plotted as follows:
- the ROC is plotted in green when above 0 (trending up) and red when below 0 (trending down).
- the 8-period SMA is plotted as a thin white line within the ROC signal
- the 64-period SMA is plotted as a thick white line within the ROC signal
When the trendline is green, this is a bullish zone. When the trendline is red, this is a bearish zone.
Moving averages (all types of moving averages) are inherently lagging signals. To compensate for that, I am offsetting each SMA series by half of its period. This may be confusing to some, but the end result is a mathematically accurate SMA signal, centered on the signal that it is providing the moving average of. It doesn't stop the lag, but it directly and obviously shows how lagged each signal is, which I personally find better to trade against.
Symbols on the top and bottom of indicator:
Yellow triangle at bottom of indicator shows where a downward trend is starting to bottom out and a buy/long opening may be available soon.
Green triangle at bottom of indicator shows that a downward trend has switched to an upward trend. This indicates a good time to buy.
Yellow triangle at top of indicator shows where an upward trend is starting to plateau and a sell/short opening may be available soon.
Red triangle at top of indicator shows that an upward trend has switched to a downward trend. This indicates a good time to sell.
Note: You may see multiple yellow triangles before seeing a green or red triangle. This can happen when multiple trend accelerations or decelerations occur within an overall green or red zone.
In addition there is a dotted line connecting the end of the 64-period SMA to the end of the 8-period SMA. This indicates the direction the trend is moving towards. When the dotted line crosses the zero line, this portrays a rough estimate of where the trend may switch from a downtrend to an uptrend or vice versa. This is the "best" time to buy or sell, depending on your strategy.
I recommend placing a SMA on your candles set to the same window size as this indicator, and also to offset that SMA to the left by half its window size. For example, a 90-period SMA should be offset by -45 periods. That will cause it to be correctly aligned with this trend signal.