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)