Matt Caruso CARS

you can choose the banchmark index in t settings. for more information about this indicator.

https://www.carusoinsights.com/caruso-adaptive-relative-strength/
HI,

im actually working on a script that emulates matt caruso cars.

I created this script that actually does a really good work, but need upgrades

I will leave the code below if someone is interested in helping me.

thanks.

declare lower;

INPUT Betalength = 40;

input Index = "SPY";

DEF avgfast = 50;

DEF avgfast1 = 10;

DEF avgslow = 100;

DEF avgslow1 = 10;

DEF avgs40 =40;

def logic = close(Index);

#RETORNOS DEL ACTIVO Y DEL ACTIVO Y COMPARABLE

def ret1 = (close - close[1]) / close[1];

def ret2 = (logic - logic[1]) / logic[1];

#BETA

def Beta = Covariance(ret1, ret2, Betalength) / Sqr(StDev(ret2, Betalength));

#ALPHA

plot alpha = ret1 - (ret2 * Beta);

alpha.AssignValueColor(if alpha >= 0 then Color.UPTICK else Color.DOWNTICK);

alpha.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

alpha.SetLineWeight(3);

#LABELS

AddLabel(yes, "Beta : " + Round(Beta, 3), Color.LIGHT_GRAY);

AddLabel(yes, "IndexChange% : " + Round(ret2, 3), Color.LIGHT_GRAY);

AddLabel(yes, "Change% : " + Round(ret1, 3), Color.LIGHT_GRAY);

#Media movil rapida + otra que la suavice

def avg1 = expaverage(alpha, avgfast);

DEF avg11 = expaverage(avg1, avgfast1);

#Media movil lenta + otra que la suavice

DEF avg2 = average(alpha, avgslow);

DEF avg22 = expaverage(avg2, avgslow1);

#SM50

DEF SM50 = WMA(alpha, avgs40);

#conditions

#def conditions1 = if ( (avg11 < avg22) and (avg11 > 0 and avg22 > 0)and (ratio>1) ) then 1 else Double.NaN;

def conditions2 = if ( (avg11 > 0 and avg22 > 0) and (SM50 > 0)) then 1 else Double.NaN;

#plot

#plot histograma1 = conditions1;

#histograma1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

#histograma1.AssignValueColor (Color.GRAY);

#histograma1.SetLineWeight(3);

plot histograma2 = conditions2;

histograma2.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

histograma2.AssignValueColor (Color.YELLOW);

histograma2.SetLineWeight(3);

DEF line = 0;

plot zeroline = line;