eykpunter

Keltner Center Of Gravity Channel ( KeltCOG )

eykpunter Uppdaterad   
I have the ambition to create a ‘landscape’ which enables the user to see the ‘mood’ of the market about the price of an instrument, simply by looking where the candles go. Prices are a simple phenomenon , they go up or down or stay the same. This is represented quite well for the short term by a candle. I recommend to study candle patterns. Prices not only fluctuate but also trend up, down or go sideways. The user should analyze this by determining the COG (Center Of Gravity) and the ‘normal’ current range by using the historical data in a lookback period.
As a COG the center line of a Donchian Channel is often used. I.m.o. a COG should be a zone, in this channel I use the gray zone of my Donchian Fibonacci Channel, The ‘normal’ range is a multiple of Average True Range, as used in a Keltner Channel. Combining the two can give a cumbersome result, as one can see in my Keltner Fibonacci Channel. In this KeltCOG channel I solved this by not using all Fibonacci levels and by making the Keltner lines strictly parallel to the nearest COG line. To do this, I use the fact that the COG lines have horizontal stretches, there I make the Keltner lines horizontal too. Only where the COG lines change value, the Keltner lines are recalculated. This way the channel gets a very regular shape with three clear zones.

Interpretation of a chart by using the KeltCOG channel.
Overbought: If the candles go higher then the blue zone, the market is hyper enthusiast, creating an overbought situation. This is often followed by a reversion to the COG.

Uptrend: If the candles form in the blue zone, the market is enthusiast and willing to pay more.

Hopeful: If the candles form in or near the upper uncolored zone, the market is hopeful and is thinking about paying more. Sometimes prices go a little up.

Content: If the candles form in the gray zone, which represents COG, the market is happy with the current prices, so these move sideways

Disappointed: If the candles form in or near the lower uncolored zone, the market is disappointed and contemplates paying less, sometimes prices go a little down.

Downtrend: If the candles form in red zone, the market doesn’t like the instrument at all, rejects the current price and is only prepared to pay less.

Oversold: If the candles form below the red zone, the market overdoes its disgust, creating an oversold situation, often followed by a reversion to the COG.
Versionsinformation:
I added a function that automatically adjusts the width of the blue and red zones when the user changes the look back periods.
For my own use I set the look back to 14 for weekly charts, to 21 for dailies, to 28 for 3hourlies and to 35 to hourly charts.
For finer intraday charts I guess the user will like even longer look back periods, but that is to his, hers or whatevers discretion.
Versionsinformation:
After comparing mij Keltner Fibonacci Channel with prvious versions of this KeltCOG Channel I came to the conclusion that all fibonacci lines are relevant because these give support and resistance. So I made it possible to use these as innerlow and innerhigh. In the inputs this can be switched off, then 0.5*ATR will be used to distance it from the nearest COG-line. Also I now think about the uncolored zones as 'accumulation zone' below the COG and 'distribution zone' above the COG, giving regard to the method of Wyckoff.
Versionsinformation:
I gave the uncolored zones the colors green and yellow and also names, i.e.: "optimistic accumulation and distribution area", which is made green and "pessimistic accumulation and distribution area" which I gave a yellow color. The gray zone is made more transparant. You can change these in the inputs if you don't like them.
Versionsinformation:
The possibility to add extra Keltner lines is added. These lines have a distance of 2 ATR from the border of the channel. These can be used to provide values for setting a take profit target. I also show extra lines in intraday timeframes to function as 'pivot points' in attempts to predict future quotes. Default setting is off , you can switch showing individual extra lines on in the inputs. Enjoy.
Versionsinformation:
New features added:
1. The script chooses a lookback period that matches the timeframe. This feature can be switched off in the inputs, allowing the user to enter the lookback manually
Remarks on the connection between lookback and timeframe: The lookback should i.m.o. be equal to the ‘look forward’. Examples: If you choose a minute chart, you probably are a day trader and you wish to estimate where the quotes might go in the next hour. Then you should choose a lookback near 60, because the cannel will then provide the range and the COG generated by the previous hour and show the relative place of the current price in this range. If you choose an hourly chart, your horizon is probably a few days, so 35 is a proper choise, If you choose a monthly chart, you might want to estimate possibilities for the coming half year, so 7 is a proper value for this argument. The scrips chooses multiples of seven due to some superstition of mine. The script values reveal my personal subjective opinion, so the user can choose other arguments.

2. The script chooses a width that matches the lookback period. This feature can be switched off in the inputs, allowing the user to enter the width manually.
Remarks on the desirable width of the channel: The ‘landscape’ of the channel is meant to encompass most candles with some of those touching the border, then one can reasonably claim that the channel shows the ‘natural range’, providing an argument to call and ‘overbought’ or ‘oversold’ if candles move outside. Interdependency with lookback is caused by the fact that both the COG and the natural range are relatively wider when the lookback is further. However because this is not a linear connection, it took me a few hours to create a non linear formula that seems to works fine.

3. A feedback label is created to show the values that are used for lookback and width and whether these originate from the script or the user. This label can be switched off. The standard arguments label provided by Trandingview only show input defaults or entries while the compiler blocks attempts to change these with the script, so some other way to inform the user on the actual values for these parameters was needed.

The purpose of these additions is that you can throw the KeltCOG in whatever timeframe without worries about the proper settings. e.g. you can toggle through different timeframes trusting that this channel remains relevant.
Versionsinformation:
I added a label “KeltCOG width ## %” in the right upper side. It shows the percent of the width of the channel from the value of its middle line. This line is sort of an average price of the instrument in the lookback period.
You can switch it off in the inputs, you can also just show the number.
It can be taken as a sort of measurement of the volatility, the wider the cannel, the more volatile the price.
I need this feature to limit risk in my system of momentum investing. In this system I use the value of the outerlow ( the purple lowest line of the channel) as stoploss level. I have eight positions in different liquid stocks of equal size. I open a position when the price moves in the blue uptrend area. To limit the risk per trade to 2 % of the total invested finances, the maximum risk of one out of eight equal positions should not be higher 16 %. If the channel is wider than 16 %, I might prefer to use the higher red innerlow, or if the channel is too wide, not take the trade.

Also changes were made to the minimum lookback period for the script setting to 14, the formula for calculating width by the script, The green area is renamed to “prudent buyers area”, the yellow area to “prudent sellers area”.
Versionsinformation:
I added two features to the channel,
The first is the option to show the last 20 of a 40 period Hull Moving Average.
Strategy: I am a fan of this line because it is very smooth, doesn’t give many false signals and everything about it has a meaning: its direction (up, sideways or down) and the position of the bars towards this line (under=down, over=up). For me the last 20 will do.
The second feature is the option to reduce the channel to a step line with colored patches. The advantage of this option is that the indicator takes no extra space in the panel, giving a better view of the candles. Disadvantage is that you don’t have values in the price scale.
I use this option in the layout with 4 panels showing 4 different timeframes of an instrument.

In the inputs you find three switches for this option under the Extra Lines heading:
“Show just nearby Fibonacci level and color patches” Switching this on will reduce the channel to a step line and the zones become color patches in which the candle moves, zones in which no candle moves are not shown as patches.
“Toggle supportive / resistive level” If you toggle this, the step line will either have a preference to run below the candles and take the color lime, this is supportive level, or to run above the candles and take the color maroon, this is resistive level. Of course the blue patches are higher than any Fibonacci line and the red patches lower, so when the candle is in such a patch both levels are equal.
“Show both channel and nearby fib level with patches” This is added to reassure the user that one form is really a variation of the other.
Creating this option required a lot of changes in the script code. I added two sets of the six lines of the channel, the values for both sets are calculated and put in variables named F1 through F6 in the top section of the script.
In the middle section I give these values to permanent lines when the proper condition is met, these retain the names Outerhigh through Outerlow and are plotted exactly as in the original script.
In the final section I give these values to patch lines when more complicated conditions are met. I named these conditions CL1 through CL6 to apply to L1 through L6 when these values are given to variables with a somewhat truncated name Outhi through Outlow. These are plotted with the display.none condition, as the plot only serves for the fill command that creates the patches. If the variable has no value, nothing is plotted and nothing is filled, this how the patches are created only when a candle in them. To ensure that there is at least on clickable item in the indicator I created the nearby fib line by checking the before mentioned CL1 throug CL6 conditions again.

Enjoy, Eykpunter.
Versionsinformation:
Example chart showing both complete channel and Nearby Fib line with patches and HMA40
Versionsinformation:
The label which states the height of the channel as percent of its middle, has been moved to a more practical place in the lower right corner. Also the layout is changed into a smaller size and a silver background.
In the inputs the text can still be brought back to just the number.
Versionsinformation:
Different modes: Channelmode and Supertrendmode

After discovering that the “Supertrend” indicator combines beautifully with the KeltCOG with de setting “show just nearby fibonacci level and color patches” activated, I decided to integrate Supertrend into this option and rename it in “Supertrendmode”.
Integration is easy because the algorithms for KeltCOG and Supertrend use the same settings (i.e. ‘multiplier’ and ‘lookback’) in the same way. I copied lines from the code by Kivanc Ozbilgic (www.tradingview.com/script/r6dAP7yi/) made it work with the KeltCOG settings.

The option "toggle supportive / resistive level" is abolished because now this nearby fifonacci level will automatically turn to supportive and change color to lime if Supertrend indicates uptrend and in downtrend to resistive colored maroon. Because the highlight color for Supertrend is between the “Support/Resistance level” and the Supertrendline, the patches of the channel colors in which the bars run, keep their colors unchanged. The colors or the highlighters are yellowish for the uptrend and reddish for the downtrend.

The inputs are regrouped, now the first option is "toggle channel mode (off) supertrend mode (on)"

The option “use Fibonacci lines as inner high and low” is abolished, the channel now always gives Fibonacci zones.

The use of this mode is the same as for supertrend, but you get the additional information of the relevant Fibonacci level and channel zone. The outside channel situation, which occurs when the market is over enthusiastic or fearful are clearly visible by the absence of patch color.

enjoy
Versionsinformation:
Added checkbox in inputs to provide an option to show just outer zones combined with supertrend
Added a tool text checkbox for automatic multiplier adjustment
Skript med en öppen källkod

I sann TradingView-anda har författaren publicerat detta skript med öppen källkod så att andra handlare kan förstå och verifiera det. Hatten av för författaren! Du kan använda det gratis men återanvändning av den här koden i en publikation regleras av våra ordningsregler. Du kan ange den som favorit för att använda den i ett diagram.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här skriptet i ett diagram?