Center Of Gravity (COG) Indicator for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Center Of Gravity or known as COG is a momentum indicator used to identify potential reversal point when hitting the upper or lower extreme channel. When price reached one end of the channel, it's most likely going to reverse and come back.

This indicator was converted to ThinkorSwim by baffled1. It can be used on any timeframes. The Center of Gravity can be a great indicator when trading in range-bound markets. You should avoid using it when the price is trending.



thinkScript Code

Rich (BB code):
input price = close;
input length = -10;
def displacement = (length / 2) + 1;
def dPrice = price[displacement];
def tmp = if !IsNaN(dPrice) then Average(dPrice, AbsValue(length)) else tmp[1] + (tmp[1] - tmp
[2]);
def tmp1 = if !IsNaN(price) then tmp else Double.NaN;
plot Data = tmp1;
Data.SetDefaultColor(color.CYAN );
Data.SetStyle(Curve.SHORT_DASH);
def pct=100;
input width=65;
def d=width/pct;
def d1=0.8*d;
def d2=1.05*d;
def d3=1.15*d;
def stdDeviation = Highestall("data" = AbsValue(tmp1 - price));
plot UpperLine = tmp1 + stdDeviation*d1;
plot LowerLine = tmp1 - stdDeviation*d1;
plot UpperLine1 = tmp1 + stdDeviation*d2;
plot LowerLine1 = tmp1 - stdDeviation*d2;
plot UpperLine2 = tmp1 + stdDeviation*d3;
plot LowerLine2 = tmp1 - stdDeviation*d3;
UpperLine.SetDefaultColor(color.red);
UpperLine1.SetDefaultColor(color.red );
UpperLine2.SetDefaultColor(color.red );
LowerLine.SetDefaultColor(color.cyan );
LowerLine1.SetDefaultColor(color.cyan );
LowerLine2.SetDefaultColor(color.cyan );
AddCloud(UpperLine,UpperLine1,color.plum,color.plum);
AddCloud(LowerLine,LowerLine1,color.green,color.dark_green);

Shareable Link

http://tos.mx/wLM6Cq
 
Last edited:
A

AcquireCurrency

New member
Is it possible to make a scan that alerts when the price of the stock is in the green or below with the COG pointing up? And obviously vice-versa when COG is pointing down and price is in or above the purple portion.

 
Last edited:
Top