Simple Study for Sean (threshold-triggered alert)This script illustrates how to create simple alerts, triggered by a share price moving above (or below) an arbitrary threshold.
Simple
WMA/LSMA - Simplified CalculationsLots of moving averages are based on a weighted sum, the most common ones being the simple (arithmetic) and linearly weighted moving average. The problems with the weighted sum approach is that when your moving average is a FIR filter then the number of operations increase with higher values of length, and when the weights are based on a complex calculation this number of operations can increase drastically!
For the common technical analyst the calculation time of moving averages can be an insignificant factor, even more when using higher time frames, however its always a good practice to seek better performances. The SMA has already a calculation where the number of operations is independent of its length, as such it can be easy to do the same for the linearly weighted moving average (WMA). This post will describe the process toward calculating a simple and efficient WMA which will then be used to provide an efficient calculation of the least squares moving average (LSMA).
Carving Impulses Responses
Remember that impulses responses fully describe the properties of moving averages, the impulse response of the WMA is a linearly decreasing function, so we'll try to calculate it without using a weighted sum. We first need to use a cumulative sum, the cumulative sum can be described as a summation from the first element of a series to the n th element of the series, where n is the current bar number, one could say that this operation is actually super inefficient, however this is not the case, as a cumulative sum can be calculated recursively as follows:
y = y + x
The cumulative sum can be described as an amplifier and posses the following impulse response:
Once the cumulative sum receive the impulse signal as input the result will always be equal to 1. This will form the basis of our simplified calculation, all we need to do transform this response into a linearly decreasing one. The full process is as follows:
Get the impulse response of the cumulative sum
Subtract this response from a linearly increasing impulse response of size length
Normalize the result such that the sum of the resulting response is equal to 1
We need a linearly increasing response of size length , this can be done by using a running sum of the original cumulative sum response, however we must make sure that the value of this response is 0 when the one of the cumulative sum is first equal to 1. Because the resulting response as a maximum value of length we need to multiply our cumulative sum response with length , then we proceed to subtraction.
Finally we need to normalize the result, the sum of a linear sequence of values starting at 1 and ending at n is given by the explicit formula : n(n+1)/2 , which in our case give length*(length+1)/2 , we divide our previous response with this result and we end up with the impulse response of a WMA. This process can be graphically described as follows:
We can then replace the impulse function by the closing price in order to get the WMA of the closing price.
Advantages And Disadvantages
The big advantage of this calculation is its efficiency, in its non functional form (you can see it in the code) the calculation of the WMA only require 9 operations regardless of the value of length against length*2 + 4 for the weighted sum approach, as such both methods are equally efficient in terms of operations as long as the length of a standard WMA is inferior to 3, which is ridiculous, as such our approach is more appropriate.
Another advantage is that Pinescript does not allow for series as length arguments in the WMA function, however here we can have a variable length for the WMA.
Of course there are disadvantages to this approach, in terms of code we require more variables for the non functional form, which create a lengthier scripts. Another disadvantage is that we can be prone to rounding errors due to the cumulative sum, however they shouldn't be significants in our case.
Getting The Least Squares Moving Average
The LSMA is one of my favorite moving averages, and it can derived from a linear combination between the WMA and SMA described as follows : 3WMA - 2SMA. Since we proposed an alternative calculation of the WMA we can then calculate the LSMA without even using the SMA, why ? because the SMA can be calculated by computing the changes over length period of the cumulative sum of an input, this result is then divided by length .
Remember that the impulse response of a cumulative sum is just a rectangular function, all we need is to truncate it such that only length values of the response are equal to 1, this is done thanks to the change function in Pine.
In Summary
A more efficient calculations for both the WMA and LSMA have been presented, while this on itself isn't super important you have learned what is the process toward calculating a filter without relying on a weighted sum.
This calculation will soon be included in the Pinecoders script allowing series as length argument.
Thank you for reading, your interest is always appreciated !
SMA 21/30/50/100/200 with Cross by DragonByteCombines several key simple moving averages into one slot without going overboard. Includes cross indicators between the 50/100 and the 50/200 day SMA's.
Function : Know Sure Thing ! (KST)Firstly : Know Sure Thing, or KST , is a momentum oscillator developed by Martin Pring to make rate-of-change readings easier for traders to interpret. In a 1992 Stocks and Commodities article, Mr. Pring referred to the indicator as "Summed Rate of Change ( KST )," but the KST term stuck with technical analysts. The indicator is relatively common among technical analysts preferring momentum oscillators to make decisions.
References : Investopedia (www.investopedia.com )
Let's start :
Simply :
KST : Above point 0 means long position (positive zone), below point 0 (negative zone) means short position.
I liked this indicator more than RSI because we can evaluate the breaking points of the channels we draw on the indicator according to the regions.
Plus area (positive area), breaking the channel upwards may indicate a very strong rise, and minus area (negative area) the channel downwards may indicate a very strong fall.
As a person who is very keen to identify major trends in advance, I like the KST indicator to approach the target quickly and simply. I also find it very successful in terms of divergences.
CAUTION : This indicator has been written before many times on TV. I have no effort on it. I saved loads only for variable periods. But I have enough experience to say that you are successful in trends with KST . Nevertheless, do not use it alone, as other promoters may benefit.
For example , I divided the standard periods into 4 as in the script. With a correct adaptive period, it has the potential to contribute greatly to accurate moves! You can use with mutable variable periods. Abundant trend lines can be drawn on the indicator and divergences between price and indicator can be sought. Best regards!
Forecasting - Simple Mean MethodThis is a continuation of my series on forecasting techniques. The idea behind the Simple Mean method is to somehow extend historical mean to the future. In this case a forecast equals to last value plus average change.
Rogers & Satchell Volatility EstimationFirst off, a huge thank you to the following people:
theheirophant: www.tradingview.com
alexgrover: www.tradingview.com
NGBaltic: www.tradingview.com
The Rogers & Satchell function is a volatility estimator that outperforms other estimators when the underlying follows a geometric Brownian motion with a drift (historical data mean returns different from zero). As a result, it provides a better volatility estimation when the underlying is trending. However, the Rogers & Satchell estimator does not account for jumps in price (gaps). It assumes no opening jump. The function uses the open, close, high, and low price series in its calculation and it has only one parameter, which is the period to use to estimate the volatility.
This script allows you to transform the volatility reading. The intention of this is to be able to compare volatility across different assets and timeframes. Having a relative reading of volatility also allows you to better gauge volatility within the context of current market conditions.
For the signal lie I chose a repulsion moving average to remove choppy crossovers of the estimator and the signal. This may have been a mistake, so in the near-future I might update so that the MA can be selected. Let me know if you have any opinions either way.
Want to Learn?
If you'd like the opportunity to learn Pine but you have difficulty finding resources to guide you, take a look at this rudimentary list: docs.google.com
The list will be updated in the future as more people share the resources that have helped, or continue to help, them. Follow me on Twitter to keep up-to-date with the growing list of resources.
Suggestions or Questions?
Don't even kinda hesitate to forward them to me. My (metaphorical) door is always open.
Meister Shredder - Simple Moving Averages x4 ForecastIncludes the 21, 50, 100 and 200 SMA and 6 bar forecast
5 Moving Average (Simple / Exponential)Defaults to 1 SMA with 4 EMA bands. 200 SMA is intended to show the trend; 20,40 and 55 EMA show entries; 81 EMA is used as stop/take profit. Defaults are inspired by 'Eric Choe' but you can switch between EMA and SMA as per your own preference. Philakone uses all 5 as EMA 8, 13, 21, 55, 200
15minMAThis script lets you plot a simple or exponential moving average from a specific time frame that you can select. For example, if you always want the Daily 50MA on your chart, regardless of what resolution your chart is on, this will do it. It's also color coded to show if it's rising or falling.
Multiple Moving Averages [clean]Very simple indicator script to display multiple simple moving averages. I know others have made this but they often are too feature-rich and can get cluttered.
Can optionally show a cross when MA 1 crosses MA 3. These are colors such that when MA 1 crosses BELOW MA 3 a red cross is shown, and green when crossing above.
Leeloo Triple Simple Moving AverageAllows you to have three simple moving averages in one indicator.
crashm111 3-200 Moving Average RibbonAll the moving averages bewteen 3 and 200 in increments of 5.
with the ability to change colours
and change between simple and exponential.
It provides an easy and fast way to determine the trend direction and possible reversals.
Moving Averages DifferenceSimple indicator for crossing moving averages to identify trend and adjust bias
Simple Moving Averages (7, 30, 50, 100, 200)7, 30, 50, 100, 200 simple moving averages, bundled in one indicator (for users who are using the free TradingView service and can only load limited number of indicators at any given time).
You can turn each moving average on or off at will and change the colors.
Binque's Multi-Moving Average Binque's Multi-Moving Average - One indicator with four simple moving average and four exponential moving averages, plus as a bonus a Day High moving average and a Day Low Moving Average.
Simple Moving Average or MA(14), MA(50), MA(100) and MA(200) all in one indicator
Exponential Moving Average or EMA(8), EMA(14), EMA(20) and EMA(33) all in one indicator
Day High Moving Average - Tracks the Daily High versus most moving averages track the daily close.
Day Low Moving Average - Tracks the Daily Low versus most moving average track the daily close.
To Disable moving averages, Set the color to the chart background and then set the length to 1 and uncheck.
I Use the Daily High Moving Average to track upward resistance in a stock movement for Swing Trading.
I Use the Daily Low Moving Average to track my trailing stop in a stock movement for Swing Trading.
Yesterday Line: Lines at Yesterday's Open, Close, High, and Lowcreated by AutemOx
twitter: @joyrider5
reddit: /u/joyrider5
This creates lines at yesterdays open, close, high, and low. It is pretty amazing use of the timenow and dayofweek variables if I say so myself 8)
Six Simple Moving Averages by HypedOnCrypto For those who use the free version and want to use more than 3 moving averages.
I wish you all a good Trade.
NG [Simple Harmonic Oscillator]The SHO is a bounded oscillator for the simple harmonic index that calculates the period of the market’s cycle.
The oscillator is used for short and intermediate terms and moves within a range of -100 to 100 percent.
The SHO has overbought and oversold levels at +40 and -40, respectively.
At extreme periods, the oscillator may reach the levels of +60 and -60.
The zero level demonstrates an equilibrium between the periods of bulls and bears.
The SHO oscillates between +40 and -40.
The crossover at those levels creates buy and sell signals.
In an uptrend, the SHO fluctuates between 0 and +40 where the bulls are controlling the market.
On the contrary, the SHO fluctuates between 0 and -40 during downtrends where the bears controlthe market.
Reaching the extreme level -60 in an uptrend is a sign of weakness.
Simple and Exponential MAAllow moving averages to be displayed without needing to use up multiple charting indicators individually (20, 50, 100, 200, 300 lengths for both EMA and SMA)