Total Trend Follow Strategy with Pyramid and DCA
Introduction
This is a Pine 4 trend following strategy. It has a twin study with several alerts. The design intent is to produce a commercial grade signal generator that can be adapted to any symbol and interval. Ideally, the script is reliable enough to be the basis of an automated trading system web-hooked to a server with API access to crypto, forex and stock brokerages. The strategy can be run in three different modes: long, short and bidirectional.
As a trend following strategy, the behavior of the script is to buy on strength and sell on weakness. As such the trade orders maintain its directional bias according to price pressure. What you will see on the chart is long positions on the left side of the mountain and short on the right. Long and short positions are not intermingled as long as there exists a detectable trend. This is extremely beneficial feature in long running bull or bear markets. The script uses multiple setups to avoid the situation where you got in on the trend, took a small profit but couldn’t get back in because the logic is waiting for a pullback or some other intricate condition.
Deep draw-downs are a characteristic of trend following systems and this system is no different. However, this script makes use of the TradingView pyramid feature accessible from the properties tab. Additional trades can be placed in the draw-down space increasing the position size and thereby increasing the profit or loss when the position finally closes. Each individual add on trade increases its order size as a multiple of its pyramid level. This makes it easy to comply with NFA FIFO Rule 2-43(b) if the trades are executed here in America. The inputs dialog box contains various settings to adjust where the add on trades show up, under what circumstances and how frequent if at all. Please be advised that pyramiding is an advanced feature and can wipe out your account capital if your not careful. During the backtest use modest setting with realistic capital until you discover what you think you can handle.
In addition to pyramiding this script employs DCA which enables users to experiment with loss recovery techniques. This is another advanced feature which can increase the order size on new trades in response to stopped out or winning streak trades. The script keeps track of debt incurred from losing trades. When the debt is recovered the order size returns to the base amount specified in the TV properties tab. The inputs for this feature include a limiter to prevent your account from depleting capital during runaway markets. The main difference between DCA and pyramids is that this implementation of DCA applies to new trades while pyramids affect open positions. DCA is a popular feature in crypto trading but can leave you with large “bags” if your not careful. In other markets, especially margin trading, you’ll need a well funded account and much experience.
Consecutive loss limit can be set to report a breach of the threshold value. Every stop hit beyond this limit will be reported on a version 4 label above the bar where the stop is hit. Use the location of the labels along with the summary report tally to improve the adaptability of system. Don’t simply fit the chart. A good trading system should adapt to ever changing market conditions. On the study version the consecutive loss limit can be used to halt live trading on the broker side (Managed manually).
Design
This script uses nine indicators on two time frames. The chart (primary) interval and one higher time frame which is based on the primary. The higher time frame identifies the trend for which the primary will trade. I’ve tried to keep the higher time frame around five times greater than the primary. The original trading algorithms are a port from a much larger program on another trading platform. I’ve converted some of the statistical functions to use standard indicators available on TradingView. The setups make heavy use of the Hull Moving Average in conjunction with EMAs that form the Bill Williams Alligator as described in his book “New Trading Dimensions” Chapter 3. Lag between the Hull and the EMAs form the basis of the entry and exit points. The alligator itself is used to identify the trend main body.
The entire script is around 1700 lines of Pine code which is the maximum incidental size given the TradingView limits: local scopes, run-time duration and compile time. I’ve been working on this script for over a year and have tested it on various instruments stocks, forex and crypto. It performs well on higher liquidity markets that have at least a year of historical data. Though it can be configured to work on any interval between 5 minutes and 1 day, trend trading is generally a longer term paradigm. For day trading the 10 to 15 minute interval will allow you to catch momentum breakouts. For intraweek trades 30 minutes to 1 hour should give you a trade every other a day. Four hours and above are for seasoned deep pocket traders. Originally, this script contained both range trading and trend following logic but had to be broken into separate scripts due to the aforementioned limitations.
Inputs to the script use cone centric measurements in effort to avoid exposing adjustments to the various internal indicators. The goal was to keep the inputs relevant to the actual trade entry and exit locations as opposed to a series of MA input values and the like. As a result the strategy exposes over 50 inputs grouped into long or short sections. Inputs are available for the usual minimum profit and stop-loss as well as safeguards, trade frequency, DCA, modes, presets, reports and lots of calibrations. The inputs are numerous, I’m aware. Unfortunately, at this time, TradingView does not offer any other method to get data in the script. The usual initialization files such as cnf, cfg, ini, json and xml files are currently unsupported.
Example configurations for various instruments along with a detailed PDF user manual is available.
Indicator Repainting And Anomalies
Indicator repainting is an industry wide problem which mainly occurs when you mix backtest data with real-time data. It doesn't matter which platform you use some form of this condition will manifest itself on your chart over time. The critical aspect being whether live trades on your broker’s account continue to match your TradingView study. Since this trading system is featured as two separate scripts, indicator repainting is addressed in the study version. The strategy (this script) is intended to be used on historical data to determine the appropriate trading inputs to apply in the study. As such, the higher time frame of this strategy will indeed repaint. Please do not attempt to trade from the strategy. Please see the study version for more information.
One issue that comes up when comparing the strategy with the study is that the strategy trades show on the chart one bar later than the study. This problem is due to the fact that “strategy.entry()” and “strategy_exit()” do not execute on the same bar called. The study, on the other hand, has no such limitation since there are no position routines. However, alerts that are subsequently fired off when triggered in the study are dispatched from the TradingView servers one bar later from the study plot. Therefore the alert you actually receive on your cell phone matches the strategy plot but is one bar later than the study plot. A lot can happen in four hours if you are trading off a 240 bar.
Please be aware that the data source matters. Cryptocurrency has no central tick repository so each exchange supplies TradingView its feed. Even though it is the same symbol the quality of the data and subsequently the bars that are supplied to the chart varies with the exchange. This script will absolutely produce different results on different data feeds of the same symbol. Be sure to backtest this script on the same data you intend to receive alerts for. Any example settings I share with you will always have the exchange name used to generate the test results.
Usage
The following steps provide a very brief set of instructions that will get you started but will most certainly not produce the best backtest. A trading system that you are willing to risk your hard earned capital will require a well crafted configuration that involves time, expertise and clearly defined goals. As previously mentioned, I have several example configs that I use for my own trading that I can share with you along with a PDF which describes each input in detail. To get hands on experience in setting up your own symbol from scratch please follow the steps below.
The input dialog box contains over 50 inputs separated into seven sections. Each section is identified as such with a makeshift separator input. There are three main areas that must to be configured: long side, short side and settings that apply to both. The rest of the inputs apply to pyramids, DCA, reporting and calibrations. The following steps address these three main areas only. You will need to get your backtest in the black before moving on to the more advanced features
Step 1. Setup the Base currency and order size in the properties tab.
Step 2. Select the calculation presets in the Instrument Type field.
Step 3. Select “No Trade” in the Trading Mode field.
Step 4. Select the Histogram indicator from section 3. You will be experimenting with different ones so it doesn’t matter which one you try first.
Step 5. Turn on Show Markers in Section 3.
Step 6. Go to the chart and checkout where the markers show up. Blue is up and red is down. Long trades show up along the blue markers and short trades on the red.
Step 7. Make adjustments to Base To Vertex and Vertex To Base net change and roc in section 3. Use these fields to move the markers to where you want trades to be. Blue is long and red is short.
Step 8. Try a different indicator from section 3 and repeat Step 7 until you find the best match for this instrument on this interval. This step is complete when the Vertex settings and indicator combination produce the most favorable results.
Step 9. Turn off Show Markers in Section 3.
Step 10. Enable the Symmetrical and Deviation calculation models at the top of section 5 and 6 (Symmetrical, Deviation).
Step 11. Put in your Minimum Profit and Stop Loss in the first section. This is in pips or currency basis points (chart right side scale)
Step 12. Return to step 3 and select a Trading Mode (Long, Short, BiDir, Flip Flop). If you are planning to trade bidirectionally its best to configure long first then short. Combine them with BiDir or Flip Flop after setting up both sides of the trade individually.
Step 13. Trades should be showing on the chart.
Step 14. Make adjustments to the Vertex fields in section 3 until the TradingView performance report is showing a profit.
Step 15. Change indicators and repeat step 14. Pick the best indicator.
Step 16. Use the check boxes in sections 5 and 6 to improve the performance of each side.
Step 17. Try adding the Correlation calculation model to either side. This model can sometimes produce a negative result but can be improved by enabling “Adhere To Markers” or “Narrow Correlation Scope” in the sections 5 and 6.
Step 18. Enable the reporting conditions in section 7. Look for long runs of consecutive losses or high debt sequences. These are indications that your trading system cannot withstand sudden changes in market sentiment.
Step 19. Examine the chart and see that trades are being placed in accordance with your desired trading model.
Step 20. Apply the backtest settings to the study version and perform forward testing.
This script is open for beta testing. After successful beta test it will become a commercial application available by subscription only. I’ve invested quite a lot of time and effort into making this the best possible signal generator for all of the instruments I intend to trade. I certainly welcome any suggestions for improvements. Thank you all in advance.
Azioni
Rolling Moving Average, SMA/EMA, for IPO stocksThe script replicates the standard EMA/SMA used by tradingview, but also adds an estimate for the first X periods, where X is the length of the moving average. This allows for an estimate of support resistance in IPO stocks, when fewer date is available
Multi-EMA | 5 EMAs in 1 ScriptAdd up to 5 EMAs to your charts with this script.
Fully Customizable.
----------------------------------------
Wanna try my other scripts?
Histogram with Divergence Finder:
Willams %R with 13 EMA and Divergence Finder:
More scripts here:
www.tradingview.com
Dynamic Weekly Price Envelope
This is a indicator that I have been developing and personally using for over a year. The basic concept is a dynamic range that is derived from the previous weeks range. The main philosophy followed when designing this indicator was that it should be applicable to all asset classes, and it should provide objective price levels of support and resistance that do not change when price approaches them. This indicator is most useful in range bound price action, but gives a lot of useful information on any market condition at a glance. The indicator also generates a custom vwap that reflects the volume weighted price since the price broke significant levels.
Indicator Description
The indicators most important price levels are the top 3 lines and the bottom 3 lines. These lines are distinguished by their wider line thickness with default settings. These levels act as support and resistance, and the price entering these regions indicates that the asset is overbought or oversold. A setting is available to highlight in red or green when price is overbought or oversold. Here is an example:
This example also demonstrates one of my personal favorite signals, which is when the price reenters the central channel, then retests the overbought/oversold region, as it does in the example, shown by the second set of red arrows.
Timeframes
This indicator reacts dynamically, so the levels will look different on different timeframes. The hourly chart works best from my experience in forex and crypto with default settings, but in general lower timeframes will give a more accurate picture during extreme price action. Note: assets that have shorter sessions generally should use a smaller timeframe. I like to use 15min on stocks, this is similar to the hour chart in crypto or forex. Take this GBPUSD chart for example:
As you can see the price has a very extreme impulse, and all resistances are passed. You can see that the lines still act as support when price falls back into the range, but the indicator is not very useful when price exits the range. The solution for this is to drop down to a lower timeframe that will adjust faster to the extreme price movement.
Here you can see that the range shifts with the price movement, indicating support levels throughout the entire price impulse.
I will also drop down to lower timeframes if I want to utilize the price levels within the channel as support and resistance levels for intraday trading. Here is an example with price level interactions indicated by red and green arrows.
THe most significant levels are still the centerline and the top and bottom three levels, but the inner lines also are nice for intraday support and resistance.
Larger time frames like the daily chart also are useful. Let's take the daily Bitcoin chart as an example:
On larger timeframes,
If price is below the central red line price is trending down, and if price is above central red line, the trend is up
The asset trading outside of the entire range indicates that the trend is very strong, reentry into the channel indicates that price is likely to consolidate.
The outer lines still serve as significant support and resistance.
Settings
I have configured the default settings to perform well for most assets, but I allow the user to change settings as they desire.
Line Color - this setting changes the color of the lines.
Fill Color - this setting changes the fill color used for the indicator
Line Transparency - The transparency of the lines, set to 100 to completely hide all lines
Base Fill Transparency - This setting changes the base transparency for the channel, this transparency will be used for the outermost bands
Transparency Gradient Step - each band will become this amount more transparent as they come closer to the centerline
Adjustment Lag - this adjusts how quickly the channel adjusts when the top and bottom levels are breached. I have always used 100, but using much higher or lower values gives interesting results.
Show Signals - This enables basic swing signals to be shown by red and green triangles. Note that this is only one signal, and the system actually has many signals outside of these triangles. They only indicate optimal entries for a swing trading technique based on the indicator.
Show Oversold/Overbought Price - ticking this box results in the fill color changing to green when price is oversold, and red when the price is overbought.
That about covers all the basics for using this indicator, please reach out with comments or messages if you would like to know anything more. Thanks for reading, and I hope you can use this tool to help your analysis. A monthly version and a refined strategy are in the works and will be published soon.
InfoPanel - SeasonalityThis panel will show which is the best month to buy a stock, index or ETF or even a cryptocurrency in the past 5 years.
Script to use only with MONTHLY timeframe.
Thanks to: RicardoSantos for his hard work.
Please use comment section for any feedback.
PpSignal WILD MA V1.19Wilder's Moving Average. Also called Wilder's Smoothed Moving Average, this indicator is similar to the Exponential Moving Average. Compared to other moving averages, Wilders MA responds more slowly to price changes, where an n-period Wilder MA gives similar values to a 2n- period EMA.
We added a standard deviation average.
buy when wilder is in blue color and standard average in aqua color.
Se ll when all is red
Beta Adjusted Volatility BandsBeat Adjusted Volatility Bands
Input Vix and Beat of the asset Sector.
Example:
Looking to sell options, Sell options beyond the bands.
BOSS EMA Trend Meter PRO With Alerts BOSS PRO TRADING SYSTEM INDICATORS
Bullish Uptrend
To determine bullish uptrend there must beat least 2 green squares on all three trend meters. This is a great predictor that a uptrend is imminent. You can set alerts for top two meters being green as well as all 3 meters being green
Bearish Downtrend
To determine bearish downtrend there must beat least 2 red squares on all three trend meters. This is a great predictor that a downtrend is imminent. You can set alerts for top two meters being red as well as all 3 meters being red.
Purchase Here: bosscripts.com
CS Buy/Sell Strategy (read the description)Get Buy/Sell signals and check their profitability in the Strategy Tester.
This script has been tested for the crypto space (Bitcoin, Ethereum, etc.) but works for other assets, as well.
I recommend to apply strategy tests on different time-frames (usually daily and 4hr work best) and go with the most profitable ones.
In the settings you have the ability to test the strategy using from - to dates to narrow down best profitable trade periods.
In order to add this strategy to your chart, click on "Add to favorite scripts" and in then, in your chart, go to Indicator and add it from your favorites.
If you have questions, please send me a message.
There is also a Long/Short focused script available with the ability to set alerts (requires an invite). If you want to add it. Just send me a message to get an invite:
Life In Stocks20 moving average with buy and sell signal, Bullish engulfing, bersish engulfing and you will get the SR in all interval of time.
CoinStudio Signals Full (read the description)CoinStudio Signals Full displays long and short, as well as reasonable targets and allows to set custom alerts based on them.
Possible targets are flagged as "C" for the most previously occurred signal. These targets indicate chances to sell before an expected reversal.
If the signals switch from let's say Short to Long and there are no targets between them, it either means the signal failed or the target is falling together with a new signal.
CoinstudioSignals work for any asset (crypto, stocks, gold , silver , etc.) and work for every time-frame.
However, daily and 4hr usually give the best results.
To add this script, please send me a message and ask for an invite!
Gap Up Stats - Gap Strategie für Aktien! Was passiert eigentlich nach einem X% Gap? Diese Frage lässt sich nun einfach beantworten! Ändere die % und die Anzahl der Jahre, welche Du testen möchtest mit nur einem Klick. Die unterschiedlichen Werte zeigen Dir dann direkt, ob sich Deine Handelsthese mit den Statistiken der Aktie deckt.
In diesem Fall sehen wir, dass die Aktie über das letzte Jahr in allen Fällen unter dem Eröffnungspreis geschlossen hat. Der durchschnittliche Spike lag bei 16%. Damit ist ein Short die richtige Wahl und die potentiellen Level der Aktie können mit der Statistik vereint werden.
Bei Interesse ist dieses Skript bei uns erhältlich.
Viele Grüße
WirmachenTrader®
CS Signals Lite (read the description)CoinStudio Signals Lite displays long and short entries.
Additionally, the Full version supports custom alerts based on the signals.
To get access to the full version and alerts, please message me for an invite.
The signals work for any asset (crypto, stocks, gold , silver , etc.).
In principle, the signals work for every time-frame but depending on the asset some work better than others.
However, daily and 4hr usually give the best results.
CS Signals Full (read the description)CoinStudio Signals Full displays long and short entries and allows to set custom alerts based on them.
The signals work for any asset (crypto, stocks, gold, silver, etc.).
In principle, the signals work for every time-frame but depending on the asset some work better than others.
However, daily and 4hr usually give the best results.
To enable this script, please head to our Discord and ask for an invite:
discord.gg
Bar RatioBar Ratio is an indicator tool that provides real-time likelihood of the current bar closing up or down (green or red).
Technical status, volatility and time are key elements in this indicator.
From the open of a bar, a ratio of 50% is assumed before changes from factors are considered.
The factors that change the likelihood of a bar closing up or down and their relative weight are listed below.
Micro-Trend observed over the last 20 bars - up to 2.5%
Macro-Trend observed over the last 70 bars - up to 2.5%
Current bar price against beginning of Micro-Trend - up to 2.5%
Combination of significant change above average volatility and move against direction of Micro-Trend - up to 2.5%
Combination of significant change above average volatility and move against direction of Macro-Trend - up to 2.5%
Previous bar direction up to 10 consecutive bars - up to 3.75%
Current status of bar (higher or lower) - up to 3.75%
Significance of change against average volatility - up to 5%
Time until bar close - up to 25%
Total: 100%
If all factors are synchronised, the likelihood of the bar closing up or down can be indicated at a probability of 100%.
While the practical ability for this to be used for trading is limited, the tool can be useful for choosing when it is safe to open a trade.
Time is a key element as the likelihood of the bar remaining at current status by the close of the bar is constantly increasing.
The accuracy of this tool is incredible and should be noted as it's primary trait.
You can find and use this indicator on any time-stamp or security such as Cryptocurrency, Forex, Stocks or Indices.
The Bar Ratio can be located by searching in your public indicator library at the top of your chart and adding it to your screen.
Directional Momentum Flux StrategyDirectional Momentum Flux (DMF) is a compound indicator designed to surface signals of projected change in directional momentum. The primary goal is to identify possible momentum inflection points and signal them before they happen, which is reached by applying a set of well-known high-level indicators (e.g. DEMA, RSIs, CCIs and VWAP), lower-level indicators (e.g. BOP, PPO and RMOMO), and some special sauce brewed in-house by yours truly.
This strategy is invite-only. Invitations are offered for a one-time fee of $250 payable in several cryptocurrencies (ETH, BTC, DASH, XMR or ZEC). Once you've got an invitation, you will automatically receive updates forever*.
DMF was designed to work across multiple asset classes. Extensive backtesting has been performed over multiple sample series (not just during the bull runs, for example) and against a randomized pool of assets. But don't take my word for it, I've included some time-based backtesting support tools to make it easy-peasy for you to validate the results yourself!
Under the hood, DMF is powered by numerous indicators, including:
✓ Double EMA & Composite SMA;
✓ Double RSI (fast & slow, variable);
✓ Composite StochRSI & VWAP (StochRSI+, two series);
✓ Composite Commodity Channel Index (CCI+, two series);
✓ Volume-Weighted Balance of Power (BOP itself was adapted from BOP_LB, kudos to LazyBear);
✓ Percentage Price Oscillator (PPO, split, two series);
✓ Range-adjusted Momentum Oscillator (RMOMO, my fancy MOM variant);
It crunches all that data and generates signals which are issued in two ways:
✓ Vertical Bands (or VBs) - Entry/Exit windows as vertical bands that remain "lit" (e.g. the background of a series of candles is semi-opaque white) while the top-level signals are showing sufficiently strong BUY signals. These windows are the primary entry/exit targets and can be relied upon with sufficient risk mitigation (e.g. a reasonable stop-loss or other scale-out exit mechanism). A VB followed immediately by an egg is as good as gold.
✓ Eggs - Entry/Exit validation signals that confirm the condition indicated by VBs. A lit VB without an egg in the same or next candle session is considered to be valid , but not safe (see above warning). Waiting for an egg can improve performance at the risk of missing the best possible entry point. Consider your risk tolerance and act accordingly.
Basic Instructions:
✓ Configure The Settings! The defaults are pretty good, but don't be scared to try variations. For example, by default SHORT positions are disabled. You might want to enable them if your risk tolerance allows them. (IMO there's gold on both ends of the rainbow. 🌈)
✓ Pay attention to the VBs. If you see a lit band being placed in an otherwise dark area, it's a projected inflection point. This is expected to be validated and confirmed in the same or immediately following period with an egg. You can enter a LONG position at this time.
✓ Pay attention to the eggs. If you see an egg, it's a confirmation that the VB changes in the same or immediately preceding candle period is valid. If you did not enter or exit your position at the point of the VB shift, now is the time to do so.
✓ Watch for the end of a VB period and be prepared to exit your position quickly as the next egg may be accompanied by a large directional momentum inflection.
Things to Note:
📉 - DMF is designed for day trading with aggressive position TTLs (15m was the upper bound during development and strategy testing). It appears to issue valid signals for other intervals, but it was not designed for >15m and YMMV. Don't go manually opening a LONG with no exit strategy and go to sleep... it probably won't work out to your benefit. You should be prepared to exit positions at any time. (Pro tip: automation is your friend!)
💸 - DMF indicator is not free from risk. As with all investment strategies, it is crucial to exercise caution and only trade with funds you are comfortable losing. DMF does not offer any form of guarantee or warranty, implied or otherwise. If you lose money, your house, your 401K... that's on you. (Pro tip: don't risk anything you're not ready to lose, because losses are part of the game and you WILL have them.)
🤔 - By using this indicator, you understand that any and all risks are the sole and complete responsibility of the end user (yeah, that's you). Don't use it if you're not 100% clear that you know exactly what you're doing. (Pro tip: always ask questions if you're feeling confused.)
⏱ - * Forever in this context means that, where room for improvement exists, I will improve it over time and you'll get all updates until I stop making them. (Pro tip: nobody lives forever.)
Intelligent Moving Average Private AccessNote: This indicator is intended for those who have been granted private access and may be more frequently updated than the previous versions.
Introduction
This indicator uses machine learning (Artificial Intelligence) to solve a real human problem.
The Moving Average is the most used indicator on the planet, yet no one really knows what pair of moving average lengths works best in combination with each other.
A reason for this is because no two moving averages are always going to be the best on every instrument, time-frame, and at any given point in time.
The " Intelligent Moving Average " solves the moving average problem by adapting the period length to match the most profitable combination of moving averages in real time.
How does the Intelligent Moving Average work?
The artificial intelligence that operates these moving average lengths was created by an algorithm that tests every single combination across the entire chart history of an instrument for maximum profitability in real-time.
No matter what happens, the combination of these moving averages will be the most profitable.
Can we learn from the Intelligent Moving Average?
There are many lessons to be learned from the Intelligent Moving Average. Most will come with time as it is still a new concept.
Adopting the usefulness of this AI will change how we perceive moving averages to work.
Limitations
Ultimately, there are no limiting factors within the range of combinations that has been programmed. The moving averages will operate normally, but may change lengths in unexpected ways - maybe it knows something we don't?
Thresholds
The range of moving average lengths is between 5 to 40.
Additional coverage resulted in TradingView server errors.
Future Updates!
This indicator will be maintained and many updates will come in the near future! Stay tuned.
View the documentation on this indicator here: www.kenzing.com
2nd Day Stats / BACKTESTING TOOL//English version below
## Deutsche Version
Was passiert am 2. Tag, nachdem wir X % am ersten Tag zurückgelegt haben? Genau dies lässt sich sehr gut backtesten und die Erkenntnisse im Markt anwenden. Dieses Tool eignet sich besonders für kleinere Aktien (Small-Caps) oder Aktien, die am Tag der Quartalszahlen große Bewegungen zurückgelegt haben. Backtesting war selten so einfach.
## English version
What happens after a strong day 1 move? Use the custom input to test, what happened after a 10% move on day one. Change the day 1 move % and the number of years to backtest. It's that simple. The tool is especially helpful for small-cap traders and for stocks after earnings.
Mega Trend Plus - S&P 500 Trend Follower / Market GaugeFirstly, 100% of the credit goes to Greg Morris @ Stockcharts.com for the article detailing the concept and most of the settings/components. I've simply implemented his idea. I haven't sought permission from him, but given that he was open with the components of the indicator I'm assuming he's happy for me to go ahead and code this in pinescript. See the article here: stockcharts.com
Okay, so this is part of a system/indicator Greg outlined in the article that he calls Trend Gauge. The idea is fairly simple: take a group of indexes that cover the breadth of the market you want to trade, track their relationship/position to their 200 period Exponential Moving Average (EMA), and assign scores to bull/bear crosses + relative location to the EMA. Once you've normalized and aggregated the scores you finish up with a trend following indicator that works surprisingly well.
This part is called Mega Trend Plus, and tracks whether an index is above or below its 200 period EMA. I'll be releasing the second part ("Trend Strength") soon. Once that's done I'll combine them to form the full "Trend Gauge" indicator.
I decided to provide the base version that people can then experiment with and tweak to their liking, so Greg's version shown in the article is smoother than the one provided here. It's up to you to play with smoothing options, and potentially tweak the weightings of the various components. Please see the script for info on what the various inputs are - I've added notes there.
So, how does it do? Well, as you can see from the chart above it works pretty well overall. The S&P 500 has been fairly trendy over the last few decades, so it's been prime territory for a system like this. It would have kept you out of the big bear markets (particularly GFC & 2015-16), and that's the goal of any trend-based system. They thrive on how little they lose, not necessarily on how much they make.
As you can see, the indicator is pretty choppy. So it's not designed (in the current configuration) to provide accurate buy/hold/sell signals. It currently functions more as a market gauge / strength indicator.
Hopefully you find this concept interesting. It's simple, but the best systems often are.
Please add comments below if you come up with an interesting configuration or variation.
Let me know if you have any queries.
DD