Insync Index Indicator for ThinkorSwim

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
The Insync Index created by Norm North to show the consolidated status of an indicator group. Essentially, it's a consensus "master oscillator" that shows when a majority of the underlying indicators are acting in sync, suggesting that a turning point is near.

Ruby:
# InSync

# This is index is formed from signals on a variety of different technical indicators, and used
# to determine extreme overbought/oversold values in the market.
# Originally coded by Eric Rasmussen and modified by Drew Griffith
#
# The InSync Index is used detect extreme levels.
# Values higher or equal to 55 are considered to be high extreme levels. (short)
# Values lower or equal than -55 are considered to be low extreme levels. (long)

# Designed for use on daily charts

declare lower;

# Data Smoothing Input
input smooth = 1;

# Study Definitions
def bbCalc = bollingerPercentB();
def macd1 = MACD(8, 17);
def macd2 = macd1 - (MACD(8, 10) - MACD(17, 20));
def rsi = reference RSI(length = 2);
def change = RateOfChange(10);
def dpo = DetrendedPriceOsc();
def eom = EaseOfMovement();
def mf = MoneyFlowIndex();
def stoch = StochasticFull("k period" = 5);
def bomp = BalanceOfMarketPower();
def cc = CCI();

# Indicator Scoring
def bb = if bbCalc > 95 then 5 else if bbCalc < 5 then -5 else 0;
def cci = if cc > 100 then 5 else if cc < -100 then -5 else 0;
def macd = if macd1 > 0 and macd2 > 0 then 5 else if macd1 < 0 and macd2 < 0 then -5 else 0;
def roc = if change > 1 and change > ExpAverage(change, 10) then 5 else if change < 1 and change < ExpAverage(change, 10) then -5 else 0;
def sto = if stoch > 80 then 10 else if stoch < 20 then -10 else 0;
def rsiW = if rsi > 95 then 5 else if rsi < 5 then -5 else 0;
def bop = if bomp > 0 and bomp > ExpAverage(bomp, 10) then 5 else if bomp < 0 and bomp < ExpAverage(bomp, 10) then
-5 else 0;
def dp = if dpo > 0 then 5 else if dpo < 0 then -5 else 0;
def emv = if eom > 0 then 5 else if eom < 0 then -5 else 0;
def mfi = if mf > 50 then 5 else if mf < 40 then -5 else 0;

# Point Sum
def sum = bb + cci + macd + roc + sto + rsiW + bop + dp + emv + mfi;

# Plots
plot inSync = ExpAverage(sum, smooth);
plot zero = if IsNaN(close) then Double.NaN else 0;
plot pos55 = if IsNaN(close) then Double.NaN else 55;
plot neg55 = if IsNaN(close) then Double.NaN else -55;
inSync.AssignValueColor(if sum > 0 then Color.RED else  Color.GREEN);
inSync.SetLineWeight(2);
zero.AssignValueColor(Color.LIGHT_GRAY);
pos55.AssignValueColor(Color.GREEN);
neg55.AssignValueColor(Color.RED);
zero.HideTitle();
pos55.HideTitle();
neg55.HideTitle();

# Alerts
alert((sum == -55), "inSync LE", "alert type" = Alert.BAR, sound = Sound.Ding);
alert((sum == 55), "inSync SE", "alert type" = Alert.BAR, sound = Sound.Ding);

A poster made a request for this indicator. I found it in Drew Griffith's GitHub. Don't know more about it. If you use it, come back here and tell us your experience.
HTH
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

The Insync Index created by Norm North to show the consolidated status of an indicator group. Essentially, it's a consensus "master oscillator" that shows when a majority of the underlying indicators are acting in sync, suggesting that a turning point is near.

Ruby:
# InSync

# This is index is formed from signals on a variety of different technical indicators, and used
# to determine extreme overbought/oversold values in the market.
# Originally coded by Eric Rasmussen and modified by Drew Griffith
#
# The InSync Index is used detect extreme levels.
# Values higher or equal to 55 are considered to be high extreme levels. (short)
# Values lower or equal than -55 are considered to be low extreme levels. (long)

# Designed for use on daily charts

declare lower;

# Data Smoothing Input
input smooth = 1;

# Study Definitions
def bbCalc = bollingerPercentB();
def macd1 = MACD(8, 17);
def macd2 = macd1 - (MACD(8, 10) - MACD(17, 20));
def rsi = reference RSI(length = 2);
def change = RateOfChange(10);
def dpo = DetrendedPriceOsc();
def eom = EaseOfMovement();
def mf = MoneyFlowIndex();
def stoch = StochasticFull("k period" = 5);
def bomp = BalanceOfMarketPower();
def cc = CCI();

# Indicator Scoring
def bb = if bbCalc > 95 then 5 else if bbCalc < 5 then -5 else 0;
def cci = if cc > 100 then 5 else if cc < -100 then -5 else 0;
def macd = if macd1 > 0 and macd2 > 0 then 5 else if macd1 < 0 and macd2 < 0 then -5 else 0;
def roc = if change > 1 and change > ExpAverage(change, 10) then 5 else if change < 1 and change < ExpAverage(change, 10) then -5 else 0;
def sto = if stoch > 80 then 10 else if stoch < 20 then -10 else 0;
def rsiW = if rsi > 95 then 5 else if rsi < 5 then -5 else 0;
def bop = if bomp > 0 and bomp > ExpAverage(bomp, 10) then 5 else if bomp < 0 and bomp < ExpAverage(bomp, 10) then
-5 else 0;
def dp = if dpo > 0 then 5 else if dpo < 0 then -5 else 0;
def emv = if eom > 0 then 5 else if eom < 0 then -5 else 0;
def mfi = if mf > 50 then 5 else if mf < 40 then -5 else 0;

# Point Sum
def sum = bb + cci + macd + roc + sto + rsiW + bop + dp + emv + mfi;

# Plots
plot inSync = ExpAverage(sum, smooth);
plot zero = if IsNaN(close) then Double.NaN else 0;
plot pos55 = if IsNaN(close) then Double.NaN else 55;
plot neg55 = if IsNaN(close) then Double.NaN else -55;
inSync.AssignValueColor(if sum > 0 then Color.RED else  Color.GREEN);
inSync.SetLineWeight(2);
zero.AssignValueColor(Color.LIGHT_GRAY);
pos55.AssignValueColor(Color.GREEN);
neg55.AssignValueColor(Color.RED);
zero.HideTitle();
pos55.HideTitle();
neg55.HideTitle();

# Alerts
alert((sum == -55), "inSync LE", "alert type" = Alert.BAR, sound = Sound.Ding);
alert((sum == 55), "inSync SE", "alert type" = Alert.BAR, sound = Sound.Ding);

A poster made a request for this indicator. I found it in Drew Griffith's GitHub. Don't know more about it. If you use it, come back here and tell us your experience.
HTH
@MerryDay Thank you so much. I searched everywhere but couldn't find it, maybe I didn't look hard enough.
 
It acts as a derivative in a sense, to spot turning points. Pretty cool how it uses other indicators to form.
A while ago I made something similar, I forget what indicators I mashed, but here it is:
Ruby:
declare lower;

input price = hl2;
input HistoType = {default STD, ROC};
input SmoothLength = 5;
def valueDiff;
def value;
def showBands;
switch (HistoType) {
case STD:
value = double.nan;
valueDiff = (Average(price, 5) - Average(price, 35));
showBands = 1;
case ROC:
value = (Average(price, 10) - Average(price, 70));
valueDiff = Average(value - value[1], SmoothLength);
showBands = 0;
}
def coeff_num = 2;
def coeff_denom = 39;
def barNum = if IsNaN( close ) then Double.NaN else barNumber();
def coeff = coeff_num / ( coeff_denom + 1 );
def diff = ValueDiff;
rec _upLine = if barNum == 1 then
if diff >= 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff >= 0 then
diff * coeff + _upLine[1] * ( 1 - Coeff )
else
_upLine[1];
rec _dnLine = if barNum == 1 then
if diff < 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff < 0 then
diff * coeff + _dnLine[1] * ( 1 - Coeff )
else
_dnLine[1];

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(7));
plot Osc = valueDiff;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
Osc.SetDefaultColor(GetColor(5));
Osc.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Osc.SetLineWeight(3);
Osc.DefineColor("Positive and Up", Color.GREEN);
Osc.DefineColor("Positive and Down", Color.dark_green);
Osc.DefineColor("Negative and Down", Color.RED);
Osc.DefineColor("Negative and Up", Color.dark_red);
Osc.AssignValueColor(if Osc >= 0 then if Osc > Osc[1] then Osc.color("Positive and Up") else Osc.color("Positive and Down") else if Osc < Osc[1] then Osc.color("Negative and Down") else Osc.color("Negative and Up"));

# -----------------------------------------------

input length = 14;
input calcLength = 5;
input smoothlength2 = 3;

def o = open;
def c = close;
def data = fold i = 0 to length
           with s
           do s + (if c > getValue(o, i)
                   then 1
                   else if c < getValue(o, i)
                        then - 1
                        else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothlength2);
def Signal = ExpAverage(Main, smoothlength2);

plot z = 0;
z.SetDefaultColor(GetColor(7));
plot difference = 0 + Main;
difference.setpaintingstrategy(paintingstrategy.histogram);
difference.AssignValueColor(if difference > 0 and difference [0] < difference[1] then color.dark_green else if Difference > 0 then color.green else if difference[0] > difference[1] and difference < 0 then color.dark_red else color.red);
difference.setlineweight(3);

#-----------------------------------

input c2 = close;
input AvgType = AverageType.Simple;
input nFast = 8;
input nSlow = 13;
input nSmooth = 5;

plot PPO = ((MovingAverage(AverageType = AvgType, c2, nFast) -
             MovingAverage(AverageType = AvgType, c2, nSlow)) /
             MovingAverage(AverageType = AvgType, c2, nSlow));

PPO.AssignValueColor(if PPO > 0
                     then color.green
                     else color.red);

plot smooth = MovingAverage(AverageType = AvgType, PPO, nSmooth);
smooth.SetPaintingStrategy(PaintingStrategy.Line);
smooth.SetDefaultColor(Color.Cyan);
smooth.hide();
ppo.hide();

plot z2 = 0;
z2.SetDefaultColor(GetColor(7));
def diff2 = ppo-smooth;
plot difference2 = diff2 * 100;
difference2.setpaintingstrategy(paintingstrategy.histogram);
difference2.AssignValueColor(if difference2 > 0 and difference2 [0] < difference2[1] then color.dark_green else if difference2 > 0 then color.green else if difference2[0] > difference2[1] and difference2 < 0 then color.dark_red else color.red);
difference2.setlineweight(3);


osc.hide();
difference.hide();
difference2.hide();

def lavg = (osc+difference+difference2)/3;
input averagetype = averagetype.hull;
plot avengers = movingaverage(averagetype, lavg);
avengers.setpaintingstrategy(paintingstrategy.histogram);
avengers.AssignValueColor(if avengers > 0 and avengers[0] < avengers[1] then color.dark_green else if avengers > 0 then color.green else if avengers[0] > avengers[1] and avengers< 0 then color.dark_red else color.red);
plot deriv = 10*((avengers[0]-avengers[1])/2);

deriv.AssignValueColor(if deriv > 0 and deriv[0] < deriv[1] then color.dark_green else if deriv > 0 then color.cyan else if deriv[0] > deriv[1] and deriv< 0 then color.cyan else color.red);
 
Here, Try this Grid, this has Insync along with few other things I like and kind of work together for the setup. Will try and post explanation too later in the day.

http://tos.mx/py1cado
This is dope i.e InSync. Got the idea from Greg Morris on how you can use that to nail oversold stocks. Will provide feedback later and thanks a lot. Btw, can you explain the other indicators, was a little confused.
 
It acts as a derivative in a sense, to spot turning points. Pretty cool how it uses other indicators to form.
A while ago I made something similar, I forget what indicators I mashed, but here it is:
Ruby:
declare lower;

input price = hl2;
input HistoType = {default STD, ROC};
input SmoothLength = 5;
def valueDiff;
def value;
def showBands;
switch (HistoType) {
case STD:
value = double.nan;
valueDiff = (Average(price, 5) - Average(price, 35));
showBands = 1;
case ROC:
value = (Average(price, 10) - Average(price, 70));
valueDiff = Average(value - value[1], SmoothLength);
showBands = 0;
}
def coeff_num = 2;
def coeff_denom = 39;
def barNum = if IsNaN( close ) then Double.NaN else barNumber();
def coeff = coeff_num / ( coeff_denom + 1 );
def diff = ValueDiff;
rec _upLine = if barNum == 1 then
if diff >= 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff >= 0 then
diff * coeff + _upLine[1] * ( 1 - Coeff )
else
_upLine[1];
rec _dnLine = if barNum == 1 then
if diff < 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff < 0 then
diff * coeff + _dnLine[1] * ( 1 - Coeff )
else
_dnLine[1];

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(7));
plot Osc = valueDiff;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
Osc.SetDefaultColor(GetColor(5));
Osc.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Osc.SetLineWeight(3);
Osc.DefineColor("Positive and Up", Color.GREEN);
Osc.DefineColor("Positive and Down", Color.dark_green);
Osc.DefineColor("Negative and Down", Color.RED);
Osc.DefineColor("Negative and Up", Color.dark_red);
Osc.AssignValueColor(if Osc >= 0 then if Osc > Osc[1] then Osc.color("Positive and Up") else Osc.color("Positive and Down") else if Osc < Osc[1] then Osc.color("Negative and Down") else Osc.color("Negative and Up"));

# -----------------------------------------------

input length = 14;
input calcLength = 5;
input smoothlength2 = 3;

def o = open;
def c = close;
def data = fold i = 0 to length
           with s
           do s + (if c > getValue(o, i)
                   then 1
                   else if c < getValue(o, i)
                        then - 1
                        else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothlength2);
def Signal = ExpAverage(Main, smoothlength2);

plot z = 0;
z.SetDefaultColor(GetColor(7));
plot difference = 0 + Main;
difference.setpaintingstrategy(paintingstrategy.histogram);
difference.AssignValueColor(if difference > 0 and difference [0] < difference[1] then color.dark_green else if Difference > 0 then color.green else if difference[0] > difference[1] and difference < 0 then color.dark_red else color.red);
difference.setlineweight(3);

#-----------------------------------

input c2 = close;
input AvgType = AverageType.Simple;
input nFast = 8;
input nSlow = 13;
input nSmooth = 5;

plot PPO = ((MovingAverage(AverageType = AvgType, c2, nFast) -
             MovingAverage(AverageType = AvgType, c2, nSlow)) /
             MovingAverage(AverageType = AvgType, c2, nSlow));

PPO.AssignValueColor(if PPO > 0
                     then color.green
                     else color.red);

plot smooth = MovingAverage(AverageType = AvgType, PPO, nSmooth);
smooth.SetPaintingStrategy(PaintingStrategy.Line);
smooth.SetDefaultColor(Color.Cyan);
smooth.hide();
ppo.hide();

plot z2 = 0;
z2.SetDefaultColor(GetColor(7));
def diff2 = ppo-smooth;
plot difference2 = diff2 * 100;
difference2.setpaintingstrategy(paintingstrategy.histogram);
difference2.AssignValueColor(if difference2 > 0 and difference2 [0] < difference2[1] then color.dark_green else if difference2 > 0 then color.green else if difference2[0] > difference2[1] and difference2 < 0 then color.dark_red else color.red);
difference2.setlineweight(3);


osc.hide();
difference.hide();
difference2.hide();

def lavg = (osc+difference+difference2)/3;
input averagetype = averagetype.hull;
plot avengers = movingaverage(averagetype, lavg);
avengers.setpaintingstrategy(paintingstrategy.histogram);
avengers.AssignValueColor(if avengers > 0 and avengers[0] < avengers[1] then color.dark_green else if avengers > 0 then color.green else if avengers[0] > avengers[1] and avengers< 0 then color.dark_red else color.red);
plot deriv = 10*((avengers[0]-avengers[1])/2);

deriv.AssignValueColor(if deriv > 0 and deriv[0] < deriv[1] then color.dark_green else if deriv > 0 then color.cyan else if deriv[0] > deriv[1] and deriv< 0 then color.cyan else color.red);
Yeah, its very similar, do you have a scanner for your code
 
btw / if you go to the originator's github, you can also get strategy code for the III, both long and short, as well as a simplified version for a watchlist column.

here's the watchlist code. i had to #-out several plots to just get down to one, which is all a watchlist can handle. hopefully, i did it right.

Code:
# InSyncLite

# This index is formed from signals on a set of different technical indicators, and used
# to determine extreme overbought/oversold values in the market.
#
# The InSyncLite is used detect extreme levels.
# Values higher or equal to 25 are considered to be high extreme levels. (short)
# Values lower or equal than -25 are considered to be low extreme levels. (long)
# The InSyncLite was built specifically for watchlists, scans, and alerts, because
# the full version is too complex to be handled during live trading in thinkorswim

# Designed for use on daily charts

declare lower;

# Data Smoothing Input
input smooth = 1;

# Study Definitions
def bbCalc = BollingerPercentB();
def rsi = reference RSI(length = 2);
def stoch = StochasticFull("k period" = 5);
def mf = MoneyFlowIndex();

# Indicator Scoring
def bb = if bbCalc > 95 then 5 else if bbCalc < 5 then -5 else 0;
def sto = if stoch > 80 then 5 else if stoch < 20 then -5 else 0;
def rsiW = if rsi > 95 then 10 else if rsi < 5 then -10 else 0;
def mfi = if mf > 50 then 5 else if mf < 40 then -5 else 0;

# Point Sum
def sum = bb + sto + rsiW + mfi;

# Plots
plot inSync = ExpAverage(sum, smooth);
#plot zero = if IsNaN(close) then Double.NaN else 0;
#plot pos25 = if IsNaN(close) then Double.NaN else 25;
#plot neg25 = if IsNaN(close) then Double.NaN else -25;
inSync.AssignValueColor(if sum > 0 then Color.RED else if sum < 0 then Color.GREEN else Color.Gray);
inSync.SetLineWeight(2);
#zero.AssignValueColor(Color.LIGHT_GRAY);
#pos25.AssignValueColor(Color.GREEN);
#neg25.AssignValueColor(Color.RED);
#zero.Hide();
#pos25.Hide();
#neg25.Hide();

# Needed for Watchlist box painting
#AssignBackgroundColor(if sum == 25 then Color.RED else if sum == -25 then Color.GREEN else Color.Gray);
 
Last edited:
btw / if you go to the originator's github, you can also get strategy code for the III, both long and short, as well as a simplified version for a watchlist column.

here's the watchlist code. i had to #-out several plots to just get down to one, which is all a watchlist can handle. hopefully, i did it right.

Code:
# InSyncLite

# This index is formed from signals on a set of different technical indicators, and used
# to determine extreme overbought/oversold values in the market.
#
# The InSyncLite is used detect extreme levels.
# Values higher or equal to 25 are considered to be high extreme levels. (short)
# Values lower or equal than -25 are considered to be low extreme levels. (long)
# The InSyncLite was built specifically for watchlists, scans, and alerts, because
# the full version is too complex to be handled during live trading in thinkorswim

# Designed for use on daily charts

declare lower;

# Data Smoothing Input
input smooth = 1;

# Study Definitions
def bbCalc = BollingerPercentB();
def rsi = reference RSI(length = 2);
def stoch = StochasticFull("k period" = 5);
def mf = MoneyFlowIndex();

# Indicator Scoring
def bb = if bbCalc > 95 then 5 else if bbCalc < 5 then -5 else 0;
def sto = if stoch > 80 then 5 else if stoch < 20 then -5 else 0;
def rsiW = if rsi > 95 then 10 else if rsi < 5 then -10 else 0;
def mfi = if mf > 50 then 5 else if mf < 40 then -5 else 0;

# Point Sum
def sum = bb + sto + rsiW + mfi;

# Plots
plot inSync = ExpAverage(sum, smooth);
#plot zero = if IsNaN(close) then Double.NaN else 0;
#plot pos25 = if IsNaN(close) then Double.NaN else 25;
#plot neg25 = if IsNaN(close) then Double.NaN else -25;
inSync.AssignValueColor(if sum > 0 then Color.RED else if sum < 0 then Color.GREEN else Color.Gray);
inSync.SetLineWeight(2);
#zero.AssignValueColor(Color.LIGHT_GRAY);
#pos25.AssignValueColor(Color.GREEN);
#neg25.AssignValueColor(Color.RED);
#zero.Hide();
#pos25.Hide();
#neg25.Hide();

# Needed for Watchlist box painting
#AssignBackgroundColor(if sum == 25 then Color.RED else if sum == -25 then Color.GREEN else Color.Gray);
Thank you @floydddd. Pardon me if I ask basic questions, I'm new in the game and trying my best to learn. Appreciate the guidance
 
i had just read an article about the use of the 3 and 8 ema , so i had those two emas on a the top price chart, i then copy pasted the first post above and noticed that the changes, red to green of the insync indi copied the conditions of the two emas, the change from red to green etc coincided with the conditions of the 3 and 8 emas! so if you wish to mimic , put a 3 and 8 ema on top price chart, then copy /paste first post in this
thread, youll see what i saw! simple!
 
i had just read an article about the use of the 3 and 8 ema , so i had those two emas on a the top price chart, i then copy pasted the first post above and noticed that the changes, red to green of the insync indi copied the conditions of the two emas, the change from red to green etc coincided with the conditions of the 3 and 8 emas! so if you wish to mimic , put a 3 and 8 ema on top price chart, then copy /paste first post in this
thread, youll see what i saw! simple!
WOW...Wow...it's really amazing like you said and simple to see the correlation. Thanks a lot for taking the time to explain further. Cheers!!!!
 
Last edited:
Yeah, its very similar, do you have a scanner for your code
Try this:
Ruby:
declare lower;

def price = hl2;
input HistoType = {default STD, ROC};
def SmoothLength = 5;
def valueDiff;
def value;
def showBands;
switch (HistoType) {
case STD:
value = double.nan;
valueDiff = (Average(price, 5) - Average(price, 35));
showBands = 1;
case ROC:
value = (Average(price, 10) - Average(price, 70));
valueDiff = Average(value - value[1], SmoothLength);
showBands = 0;
}
def coeff_num = 2;
def coeff_denom = 39;
def barNum = if IsNaN( close ) then Double.NaN else barNumber();
def coeff = coeff_num / ( coeff_denom + 1 );
def diff = ValueDiff;
rec _upLine = if barNum == 1 then
if diff >= 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff >= 0 then
diff * coeff + _upLine[1] * ( 1 - Coeff )
else
_upLine[1];
rec _dnLine = if barNum == 1 then
if diff < 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff < 0 then
diff * coeff + _dnLine[1] * ( 1 - Coeff )
else
_dnLine[1];

def ZeroLine = 0;
def Osc = valueDiff;
def UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
def DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;


# -----------------------------------------------

input length = 14;
input calcLength = 5;
input smoothlength2 = 3;

def o = open;
def c = close;
def data = fold i = 0 to length
           with s
           do s + (if c > getValue(o, i)
                   then 1
                   else if c < getValue(o, i)
                        then - 1
                        else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothlength2);
def Signal = ExpAverage(Main, smoothlength2);

def z = 0;
def difference = 0 + Main;

#-----------------------------------

input c2 = close;
input AvgType = AverageType.Simple;
input nFast = 8;
input nSlow = 13;
input nSmooth = 5;

def PPO = ((MovingAverage(AverageType = AvgType, c2, nFast) -
             MovingAverage(AverageType = AvgType, c2, nSlow)) /
             MovingAverage(AverageType = AvgType, c2, nSlow));


def smooth = MovingAverage(AverageType = AvgType, PPO, nSmooth);

def z2 = 0;

def diff2 = ppo-smooth;
def difference2 = diff2 * 100;


def lavg = (osc+difference+difference2)/3;
input averagetype = averagetype.hull;
def avengers = movingaverage(averagetype, lavg);
def deriv = 10*((avengers[0]-avengers[1])/2);

plot sig = deriv crosses above 0 within 1 bars; #set 5 to whatever you want
 
Try this:
Ruby:
declare lower;

def price = hl2;
input HistoType = {default STD, ROC};
def SmoothLength = 5;
def valueDiff;
def value;
def showBands;
switch (HistoType) {
case STD:
value = double.nan;
valueDiff = (Average(price, 5) - Average(price, 35));
showBands = 1;
case ROC:
value = (Average(price, 10) - Average(price, 70));
valueDiff = Average(value - value[1], SmoothLength);
showBands = 0;
}
def coeff_num = 2;
def coeff_denom = 39;
def barNum = if IsNaN( close ) then Double.NaN else barNumber();
def coeff = coeff_num / ( coeff_denom + 1 );
def diff = ValueDiff;
rec _upLine = if barNum == 1 then
if diff >= 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff >= 0 then
diff * coeff + _upLine[1] * ( 1 - Coeff )
else
_upLine[1];
rec _dnLine = if barNum == 1 then
if diff < 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff < 0 then
diff * coeff + _dnLine[1] * ( 1 - Coeff )
else
_dnLine[1];

def ZeroLine = 0;
def Osc = valueDiff;
def UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
def DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;


# -----------------------------------------------

input length = 14;
input calcLength = 5;
input smoothlength2 = 3;

def o = open;
def c = close;
def data = fold i = 0 to length
           with s
           do s + (if c > getValue(o, i)
                   then 1
                   else if c < getValue(o, i)
                        then - 1
                        else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothlength2);
def Signal = ExpAverage(Main, smoothlength2);

def z = 0;
def difference = 0 + Main;

#-----------------------------------

input c2 = close;
input AvgType = AverageType.Simple;
input nFast = 8;
input nSlow = 13;
input nSmooth = 5;

def PPO = ((MovingAverage(AverageType = AvgType, c2, nFast) -
             MovingAverage(AverageType = AvgType, c2, nSlow)) /
             MovingAverage(AverageType = AvgType, c2, nSlow));


def smooth = MovingAverage(AverageType = AvgType, PPO, nSmooth);

def z2 = 0;

def diff2 = ppo-smooth;
def difference2 = diff2 * 100;


def lavg = (osc+difference+difference2)/3;
input averagetype = averagetype.hull;
def avengers = movingaverage(averagetype, lavg);
def deriv = 10*((avengers[0]-avengers[1])/2);

plot sig = deriv crosses above 0 within 1 bars; #set 5 to whatever you want
Thank you
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
378 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top