OPEN-SOURCE SCRIPT
๐ธ๐๐๐๐๐ ๐ฏ. ๐ท๐๐๐๐๐๐ ๐ธ๐๐๐๐๐ ๐ฌ๐๐๐๐๐๐ | ๐ธ๐๐๐๐๐๐๐ธ๐๐๐๐๐

The ๐ธ๐๐๐๐๐ ๐ฏ. ๐ท๐๐๐๐๐๐ ๐ธ๐๐๐๐๐ ๐ฌ๐๐๐๐๐๐ is my latest creation of a trend following tool, which is a bit different from the rest. By trying to de-lag the classical moving average, it gives you fast signals on changes in trend as fast as possible, keeping traders & investors always in check for potential risks they might want to avoid.
How does it work?
First we need to calculate lengths. The lengths are calcuted using a user defined input called the "Length Multiplier" and we of course need as well the length input too.
The indicator uses 10 lengths, 5 for an average price, 5 for median price.
The length for the average is the following:
length_2_avg = length_1_avg * length_multiplier
length_3_avg = length_2_avg * length_multiplier
...
and for the median lengths:
length_1_median = length_2_avg
length_2_median = length_3_avg
Here applies this rule
length_x_median < length_x_avg
This is intentional, and it is because the average is a little more reactive, while the median is a bit slower. To make up for the "slowness" of the median, we simple reduce the length of it a bit more than the average.
Now that we have our length we are ready to calculate averages and medians over their respective period. This is the a normal average from elementary school, nothing too fancy.
Now that we have all of them we match the pairs using another user defined input called "Median Weight" like so:
(Average_x * (2-median_weight) + Median_x * median_weight)/2
This gives more weight to the average (also due to the max value limit set to avoid breaking the fundational logic behind it).
After doing it to all the pairs we now average those pairs using another input called "Exponential Weight Multiplier".
The Exponential Weight Multiplier is used for weights which I will cover soon:
weight1 = weight
weight2 = weight * weight
weight3 = weight * weight * weight....
This is done until we have all the weights calculated
This gives exponentially more weight to the less lagging indicators, which is how we delag the indicator.
Then we sum all the pairs like so:
sum = pair1 * weight1 + pair2 * weight2 + pair3 * weight3 + pair4 * weight4 + pair5 * weight5
Then the sum is divided by the sum of weights, this results in us getting the final value.
Methodology & What is the actual point & how was it made?
I want to cover this one a bit deeper:
The methodology behind this was creating an indicator that would not be lagging, and would be able to avoid lag while not producing signals too often.
In many attempts in the first part, I tried using EMA, RMA, DEMA, TEMA, HMA, SMA and so on, but they were too noisy (except for SMA & RMA, but those had their flaws), so I tried the classical average taught in elementary school. This one worked better, but the noise was too high still after all this time. This made me include the median, which helped the noise, but made it far too lagging.
Here came the idea of making the median length lower and adding weights to counter the lag of the median, but it was still too lagging. This made me make the weights for lengths more exponential, while previously they were calculated using a little bit amplified sums that were alright, but nowhere near my desired result.
Using the new weights I got further, and after a bit of testing I was sattisfied with the results.
The logic for the trend was a big part in my development part, there were many I could think of, but not enough time to try them, so I stuck to the usual one, and I leave it up to YOU to beat my trend logic and get even better results.
Use Cases:
- Price/MA Crossovers
Simple, effective, useful
- Source for other indicators
This I tried myself, and it worked in a cool way, making the signals of for example RSI much smoother, so definitely try it out if you know how to code, or just simply put it in the source of the RSI.
- ROC
This trend logic stuck with me, I think you could find a way to make it good, but mainly for the people that can code in pine, trying out to combine the trend logic with ROC could work very well, do not sleep on it!
- Education
This concept is not really that complex, so for people looking for new ideas, inspiration, or just watching how trend following tools behave in general this is something that could benefit anyone, as the concept can be applied to ANYTHING, even the classical RSI, MACD, you could try even the Parabolic SAR, maybe STC or VZO, there is no limit to imagination.
- Strategy creation
Filtering this indicator with "and" conditions, or maybe even "or" or anything really could be very useful in a strategy that desires fast signals.
- Price Distance from bands
I noticed this while looking at past performance:
The stronger the trend the higher the distance from the Moving Average.
Final Notes
Watch out for mean reverting markets, as this is trend following you could get easily screwed in them.
Play around with this if it fits your desired outcome, you might find something I did not.
Hope you find it useful,
See you next time!
How does it work?
First we need to calculate lengths. The lengths are calcuted using a user defined input called the "Length Multiplier" and we of course need as well the length input too.
The indicator uses 10 lengths, 5 for an average price, 5 for median price.
The length for the average is the following:
length_2_avg = length_1_avg * length_multiplier
length_3_avg = length_2_avg * length_multiplier
...
and for the median lengths:
length_1_median = length_2_avg
length_2_median = length_3_avg
Here applies this rule
length_x_median < length_x_avg
This is intentional, and it is because the average is a little more reactive, while the median is a bit slower. To make up for the "slowness" of the median, we simple reduce the length of it a bit more than the average.
Now that we have our length we are ready to calculate averages and medians over their respective period. This is the a normal average from elementary school, nothing too fancy.
Now that we have all of them we match the pairs using another user defined input called "Median Weight" like so:
(Average_x * (2-median_weight) + Median_x * median_weight)/2
This gives more weight to the average (also due to the max value limit set to avoid breaking the fundational logic behind it).
After doing it to all the pairs we now average those pairs using another input called "Exponential Weight Multiplier".
The Exponential Weight Multiplier is used for weights which I will cover soon:
weight1 = weight
weight2 = weight * weight
weight3 = weight * weight * weight....
This is done until we have all the weights calculated
This gives exponentially more weight to the less lagging indicators, which is how we delag the indicator.
Then we sum all the pairs like so:
sum = pair1 * weight1 + pair2 * weight2 + pair3 * weight3 + pair4 * weight4 + pair5 * weight5
Then the sum is divided by the sum of weights, this results in us getting the final value.
Methodology & What is the actual point & how was it made?
I want to cover this one a bit deeper:
The methodology behind this was creating an indicator that would not be lagging, and would be able to avoid lag while not producing signals too often.
In many attempts in the first part, I tried using EMA, RMA, DEMA, TEMA, HMA, SMA and so on, but they were too noisy (except for SMA & RMA, but those had their flaws), so I tried the classical average taught in elementary school. This one worked better, but the noise was too high still after all this time. This made me include the median, which helped the noise, but made it far too lagging.
Here came the idea of making the median length lower and adding weights to counter the lag of the median, but it was still too lagging. This made me make the weights for lengths more exponential, while previously they were calculated using a little bit amplified sums that were alright, but nowhere near my desired result.
Using the new weights I got further, and after a bit of testing I was sattisfied with the results.
The logic for the trend was a big part in my development part, there were many I could think of, but not enough time to try them, so I stuck to the usual one, and I leave it up to YOU to beat my trend logic and get even better results.
Use Cases:
- Price/MA Crossovers
Simple, effective, useful
- Source for other indicators
This I tried myself, and it worked in a cool way, making the signals of for example RSI much smoother, so definitely try it out if you know how to code, or just simply put it in the source of the RSI.
- ROC
This trend logic stuck with me, I think you could find a way to make it good, but mainly for the people that can code in pine, trying out to combine the trend logic with ROC could work very well, do not sleep on it!
- Education
This concept is not really that complex, so for people looking for new ideas, inspiration, or just watching how trend following tools behave in general this is something that could benefit anyone, as the concept can be applied to ANYTHING, even the classical RSI, MACD, you could try even the Parabolic SAR, maybe STC or VZO, there is no limit to imagination.
- Strategy creation
Filtering this indicator with "and" conditions, or maybe even "or" or anything really could be very useful in a strategy that desires fast signals.
- Price Distance from bands
I noticed this while looking at past performance:
The stronger the trend the higher the distance from the Moving Average.
Final Notes
Watch out for mean reverting markets, as this is trend following you could get easily screwed in them.
Play around with this if it fits your desired outcome, you might find something I did not.
Hope you find it useful,
See you next time!
Aรงฤฑk kaynak kodlu komut dosyasฤฑ
Gerรงek TradingView ruhuna uygun olarak, bu komut dosyasฤฑnฤฑn oluลturucusu bunu aรงฤฑk kaynaklฤฑ hale getirmiลtir, bรถylece yatฤฑrฤฑmcฤฑlar betiฤin iลlevselliฤini inceleyip doฤrulayabilir. Yazara saygฤฑ! รcretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayฤฑnlamanฤฑn Site Kurallarฤฑmฤฑza tabi olduฤunu unutmayฤฑn.
Feragatname
Bilgiler ve yayฤฑnlar, TradingView tarafฤฑndan saฤlanan veya onaylanan finansal, yatฤฑrฤฑm, iลlem veya diฤer tรผrden tavsiye veya tavsiyeler anlamฤฑna gelmez ve teลkil etmez. Kullanฤฑm ลartlarฤฑ'nda daha fazlasฤฑnฤฑ okuyun.
Aรงฤฑk kaynak kodlu komut dosyasฤฑ
Gerรงek TradingView ruhuna uygun olarak, bu komut dosyasฤฑnฤฑn oluลturucusu bunu aรงฤฑk kaynaklฤฑ hale getirmiลtir, bรถylece yatฤฑrฤฑmcฤฑlar betiฤin iลlevselliฤini inceleyip doฤrulayabilir. Yazara saygฤฑ! รcretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayฤฑnlamanฤฑn Site Kurallarฤฑmฤฑza tabi olduฤunu unutmayฤฑn.
Feragatname
Bilgiler ve yayฤฑnlar, TradingView tarafฤฑndan saฤlanan veya onaylanan finansal, yatฤฑrฤฑm, iลlem veya diฤer tรผrden tavsiye veya tavsiyeler anlamฤฑna gelmez ve teลkil etmez. Kullanฤฑm ลartlarฤฑ'nda daha fazlasฤฑnฤฑ okuyun.