Trend Step - TrailingTrend Step - Trailing Stop is a moving average-based trailing stop that moves in pre-defined steps. In this way, the user can set the number of pips/points they want the trailing to move in relation to the movements in the average. You can also see it as trend steps. Every step represents the trend movement.
Usage
Use it as a trailing stop or as a trend direction tool.
Disclaimer: No financial advice, only for educational/entertainment purposes.
Trendstep
Uhl MA Crossover SystemToday proposed indicator is based on the corrected moving average, an indicator originally proposed by Andreas Uhl professor at Salzburg University. This moving average is not the most well known, which is a pity since its design is extremely elegant.
The corrected moving average (CMA) is an adaptive moving average based on exponential averaging and aim to correct common problems of classical moving averages such as crosses occurring during sideway markets, more details will be introduced in the calculation section. The CMA aim to act as a slow moving average in a moving average crossover system.
Here a new fast adaptive moving average named corrected trend step (CTS) based on the CMA is introduced in order to provide a full moving average crossover system based on A. Uhl design.
To Andreas Uhl
Calculation And Understanding The CTS
Even if the code is quite compact, the original idea behind the CMA can be blurry for some users, however it is actually relatively simple to understand. The CMA is based on exponential averaging and a smoothing variable is therefore required, in the CMA the calculation of the smoothing variable is based on the squared distance between the precedent CMA output and a simple moving average, and the rolling variance, where the rolling variance act as threshold.
The CTS work the same way but instead of using the squared error between a simple moving average and the previous CMA output, we use the squared error between the closing price and the previous CTS output, this allow the CTS to better fit with the closing price. As said before the rolling variance act as threshold, if the squared error is lower than the rolling variance this mean that the CTS is close to the price, which can indicate a sideway market, therefore we should filter the entirety of the current price, therefore on sideways market the CTS is equal to the precedent value of the CTS.
In trending/volatile markets we expect the price to go away from the CTS, thus having an high squared error, if the squared error is greater than the rolling variance, the smoothing variable is equal to 1 - variance/squared error , here variance/squared error < 1 since the squared error is greater than the rolling variance ( remember that the smoothing variable need to be in a (0,1) range ), however if the squared error is way higher than variance this ratio will be small, which would return a non reactive output, but thats not what we want ! This is why we subtract 1 by this ratio in order to make the CTS more reactive instead of less reactive.
In case the squared error is greater than the rolling variance during sideway markets we would not expect a huge difference anyway, that is squared error ≈ variance and therefore:
1 - variance/squared error ≈ 1 - 1/1 ≈ 1 - 1 ≈ 0
This is a beautiful way to make an adaptive moving average, the CMA is not a flashy indicator, but when we look at the details behind the design we can only get amazed, or maybe that its just me, truly a great adaptive moving average.
The System
length control the filtering amount of both moving averages, with higher values of length returning larger filtering amount. Mult multiply the rolling variance by an user selected value, this also allow a greater amount of filtering.
The CTS act as a fast moving average while the CMA act as a slow moving average.
Here the indicator with length = 200, we can see how a sideway market who could have generated a large amount of signals don't affect our system.
Unlike classical crossovers systems where the slow moving average will rarely produce a cross with the fast moving average and price at the same time, the Uhl system can actually do that:
Conclusion
A moving average crossover system based on the corrected moving average proposed by Andreas Uhl has been presented, a new moving average that aim to produce good fits with the price has been created especially for this system. The logic behind the CMA has also been explained. A possible strategy analysis could be presented in the future.
In conclusion i would say the CMA is a bit underrated, in a field where arrows, signals, alerts are the only things appreciated by peoples, original content is slowly dying, this actually make today technical indicators have a pretty bad academic reputations. I'am afraid that today haiku master is Uhl rather than me, i hope to see more indicators from him in the future.
Thanks for reading !
Original paper: www.buero-uhl.de
Efficient Trend Step ChannelIntroduction
The efficient trend-step indicator is a trend indicator that make use of the efficiency ratio in order to adapt to the market trend strength, this indicator originally aimed to remain static during ranging states while fitting the price only when large variations occur. The trend step indicator family unlike most moving averages has a boxy appearance and could therefore not be classified as smooth, this makes it an indicator relatively uninteresting to use as input for other non-trending indicators such as oscillators.
Today a channel indicator making use of the efficient trend-step is proposed, the indicator has an upper and a lower extremity who can be used for breakout or support and resistance methodologies, however we will see that the indicator is sometimes able to return accurate support and resistance levels.
The Indicator
The indicator has the same settings has the efficient trend step indicator, length control the period of the efficiency ratio, fast control the period of the rolling standard deviation used for trending states, slow control the period of the rolling standard deviation used for ranging states, fast should be lower than slow , if both are equal then the indicator is equal to the classical trend step indicator and length does no longer affect the indicator output. Lower values of fast/slow will make the indicator more reactive to small variations thus changing direction more often.
The color changes you can see on the indicator are changed depending on the prior direction took by the indicator output, if the indicator where higher than its precedent value, then the color will be blue until the indicator is lower than its precedent value. Those colors help you have an estimate of the current trend direction.
Channel Calculation And Role
The extremities made from the efficient trend step allow for more advanced trading rules, they can act as stop/target level and can also give a rough estimate of the current market volatility, with wider extremities indicating a more volatile market.
The extremities are made directly from the dev element used by the efficient trend-step, the upper extremity is made by summing the efficient trend step with the value of dev when the efficient trend step change, the lower extremity is made the same way but the value is subtracted instead.
Is it a weird choice ? It sure is strange to see such approach, the absolute rolling average error between the price and the efficient trend step could have been a logical measure but using dev instead is more efficient and also allow for a more adaptive approach which can benefit the support and resistance methodology, the last reason is because i didn't wanted to "denature" the trend-step signature of the indicator.
The figure above represent the measurement used for making the extremities (in green).
Since the previously described measure change only when the efficient trend step change, we can conclude that such measure is representative of a relatively large variation, since the efficient trend step aim to only change when a large variations appear.
We can see that the upper extremity acted as an accurate resistance in this upper variation of AMD,
Here as well, however like other bands indicators it is safer to take into account the current trend direction, a strong uptrend will have less difficulties crossing the upper extremity, therefore it might be better to rely on the support (lower extremity) on an up-trending market (indicator in blue), and on the resistance (upper extremity) on an down-trending market (indicator in orange).
The figure above show support and resistances signals, a cross represent a false signal, while green arrows represent correct ones with their respective direction.
Conclusion
The presented indicator add more possibilities to the interpretation of the efficient trend step, the extremities can act as stop/target level, however this use has to be controlled, and the level should be in accordance to your risk/reward ratio.
Showcasing another trend-step indicator was a real pleasure. Thanks for reading :)
Setting-Less Trend-Step FilteringIntroduction
Indicators settings have been a major concern in trading strategies, in order to provide the best results each indicators involved in the strategy must have its settings optimized, when using only 1 indicator this task can easily be achieved, but an increasing number of indicators involve more slower computations, lot of softwares will use brute force for indicators settings optimization, this involve testing each indicator settings and see which setting/combination maximize the equity, in order to fasten this process softwares can use a user defined range for the indicator settings. Nonetheless the combination that maximize the equity at time t might be different at time t+1...n .
Therefore i propose an indicator without any numerical setting that aim to filter small price variations using the architecture of the T-step lsma, such indicator can provide robust filtering and can therefore be used as input for other indicators.
Robustness Vs Non Robustness
Robustness is often defined as the ability of certain statistical tools to be less affected by outliers, outliers are defined as huge variations in a data-set, high volatility movements and large gaps might be considered as outliers. However here we define robustness as the ability of an indicator to be non affected by price variations that are not correlated with the main trend, which can be defined in technical analysis as pullbacks.
Some small pullbacks in INTEL, the indicator is not affected by them, which allow the indicator to filter the price in a "smart" way.
This effect is made possible by using exponential averaging in the indicator, exponential averaging is defined as y = sc*x + (1-sc)*y , with 1 > sc > 0 . Here sc is calculated in a similar way as the kalman gain, which is in the form of a/(a + b) , in our case this is done with :
sc = abs(input - nz(b ))/(abs(input - nz(b )) + nz(a ))
Non Robust Version Of The Indicator
The user is allowed to use the non robust version of the indicator by unchecking "robust" in the setting panel, this allow a better fit with the price at the cost of less filtering.
robust checked
robust unchecked
Conclusion
I proposed a technical indicator that aim to filter short frequencies without the use of parameters, the indicator proven to be robust to various pullbacks and therefore was able to follow the main trend, although using the term trend for such small price variations might be wrong. Removing high frequencies is always beneficial in trading, noisy series are harder to manipulate, this is why you'll see a lot of indicators using median price often defined as hl2 instead of the closing price.
Like previous settings-less indicators i published this one can behave differently depending on the time frame selected by the user, lower time frames will make the indicator filter more. I'll try to make more setting-less indicators that will correct this effect.
Acknowledgements
The support and interest of the community is only thing that allowed me to be where i'am today, i'am thankful. Special thanks to the tv staff, LucF, and my family who may not have believed in this project but are still proud of their son.
T-Step LSMAIntroduction
The trend step indicator family has produced much interest in the community, those indicators showed in certain cases robustness and reactivity. Their ease of use/interpretation is also a major advantage. Although those indicators have a relatively good fit with the input price, they can still be improved by introducing least-squares fitting on their calculations. This is why i propose a new indicator (T-Step LSMA) which aim to gather all the components of the trend-step indicator family (including the auto-line family).
The indicator will use as a threshold the mean absolute error between the input and the output (T-Channel) scaled with the efficiency ratio (Efficient Trend Step) while using least squares in order to provide a better fit with the price (Auto-Filter).
The Indicator
The interpretation of the indicator is easy, the indicator estimate an up-trending market when in blue, down-trending when in orange, the signal only depend on the trend-step part ( b in the code).
length control the period of the efficiency ratio as well as any components in the lsma calculation. The efficiency ratio allow to provide adaptivity, therefore the threshold will be lower when market is trending and higher when market is ranging.
Sc control the amount of feedback of the indicator, a value of 1 will use only the closing price as input, a value of 0.5 will use 50% of the closing price/indicator output as input, this allow to get smoother results.
It is possible to get the non-smooth version of the indicator by checking "No Smoothing".
This allow the indicator to filter more information.
Least Squares Smoothing - Benefits
One could ask why introducing least squares smoothing, there are several reasons to this choice, we have seen that trend-step indicators are boxy, they filter most of the variational information in the price, introducing least squares smoothing allow to gain back some of this variational information while providing a better fit with the price, the indicator is more noisy but also more practical in certain situations.
For example the indicator in its boxy form can't really be useful as input for other indicators, which is not the case with this version.
Relative strength index of period 14 using the proposed indicator as input.
Down-Sides
The indicator is dependent on the time frame used, larger time frames resulting in an indicator overfitting, sticking with lower time frames might be ideal. The indicator behavior might also change depending on the market in which it is applied.
Setting Up Alerts For The Indicator
Alerts conditions are already set, in order to create an alert based on the indicator follow these steps :
Go to the alert section (the alarm clock) -> create new alert -> select T-Step LSMA in condition -> Below select Up or Dn (Up for a up-trending alert and Dn for a down-trending alert)
In option select "once per bar close", change the message if you want a personalized message.
Conclusion
I don't think i'll post other indicators related to the trend-step framework for the time to comes, nonetheless the ones posted proven to have interesting results as well as many upsides. Although i don't think they would generate positive long-terms returns they could still be of use when using smarter volatility metrics as threshold. The proposed indicator conserve more information than its relatives and might find some use as input for other indicators.
Recommended Use Of The Code
Although i don't put restrictions on the code usage, i still recommend creative and pertinent changes to be made, graphical changes or any minor changes are not necessary, remember that such practice is disrespectful toward the author, you don't want to load up the tradingview servers for nothing right ?
Support Me
Making indicators sure is hard, it takes time and it can be quite lonely to, so i would love talking with you guys while making them :) There isn't better support than the one provided by your friends so drop me a message.