KyleBaran

Channel Lookback: Average Moving Price (CLAMP)

KyleBaran Updated   
How it works
This is a confirmation indicator based on moving averages. It compares the current price to a previous candle N periods ago, then smooths the result.
What makes this indicator novel is that it takes the smoothed curve and compares it to the previous value to see whether the slope is increasing or decreasing. Combined with a zero-cross baseline channel, we can compare the relative position of the curve, slope, or closing price to create entry signals. There are several hardcoded conditions that it checks, but this is easily changed.

Markets
The default values are best used on the SPY daily chart. With backtesting, it seemed to perform fairly well during the last year. It seems to be more accurate during choppy/bear markets, and very inaccurate during a trending market.
Eg, if you look at the period of growth that occurred during 2020, it basically said to keep shorting for months at a time. Not good. If you look at other markets (such as gold or uranium), it worked, but only if you inversed what the signal told you to do (eg going long when it says to go short). This is something you will have to test yourself, since every system and market is different. Please don't use this indicator by itself.

How to use
When combined with other indicators, this tells you whether to go long (green), go short (red), or no trade (gray). It is meant to be used as a confirmation indicator, so it will help verify other trade signals.
You can sometimes ignore the first grey circle and reuse the previous colored signal. There are a few markets (such as gold) I noticed this was helpful on; this will depend on your own trade rules and indicator system.
If you enable "simple mode" on the settings, it will draw only the final signal (long, short, no signal). I included this because it helps to reduce visual clutter.
Release Notes:
Updated to hopefully be easier to use / less clutter in the code. Usage is still pretty much the same: green dots are a long signal, red dots are a short signal. The color is determined simply by the color of the slope (blue/downward slope is a short signal, yellow/upward slope is a long signal).

You can make your own copy and attach additional rules in your own code, which can account for lines crossing, whether the dots are in one of the channels, etc.

As long as your baseline's signals agree with the color of the dots, it seems to be pretty reliable, but of course everyone trades a different system so please test it thoroughly.
Release Notes:
- Removed "simple mode" setting
- Added "draw shape" setting
- Instead of circles, output shapes are now triangles or crosses. The logic is the same as before but the trend is now more obvious. When the line is yellow it is a bullish trend; if the symbol is higher than the previous value, it will be an upward green triangle. If the symbol is lower than the previous value (moving against the trend), it will be a green X. This shows that a possible reversal in the trend may be forming.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?