forexpirate

Indicator Integrator

Here is a light piece of code, The Indicator Integrator. It sums up a function (like an integral for you calculus folks). Unlike the 'cum' function that does a million bars of look back you can change the look back period, like limits of integration.
Built in is a difference of the close from an SMA. And there is an ROC. By changing what is summed up in the loop you can sum up the differences from the SMA or sum up the ROC. Pick your SMA length/ROC length. Then pick your look back period of how much to add up (bars to add up). There is a built in SMA smoother of three bars on the final summation.

Comments welcomed
Script open-source

Nello spirito di condivisione promosso da TradingView, l'autore (al quale vanno i nostri ringraziamenti) ha deciso di pubblicare questo script in modalità open-source, così che chiunque possa comprenderlo e testarlo. Puoi utilizzarlo gratuitamente, ma il riutilizzo del codice è subordinato al rispetto del Regolamento. Per aggiungerlo al grafico, mettilo tra i preferiti.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.

Vuoi usare questo script sui tuoi grafici?
//@version=2
study("Indicator Integrator")
l = input(defval=20,title="Length for indicator",type=integer)
s = input(title="Length of summation",type=integer,defval=40)
a= sma(close,l)
r=roc(close,l)
k=close-a
sum = 0
for i = 0 to s
    sum := sum + k[i]
bc =  iff( sum > 0, white, teal)
plot(sum,color=bc, transp=20, linewidth=3,style=columns)
plot(sma(sum,3),color=white)
hline(0)