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
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?
//@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)