ChrisMoody

CM_Twiggs Money Flow

Full Credit goes to LazyBear for publishing Original Code.
I added:
Threshold lines that changes the color of Histogram based on if it exceeds Threshold lines. Ability to turn off and on.
Ability to Turn Histogram Off/On
Ability to turn Twiggs Money Flow Line Off/On

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
// @author LazyBear
// @credits http://www.incrediblecharts.com/indicators/twiggs_money_flow.php
// If you use this code in its original/modified form, do drop me a note. 
//Two Features Added by User ChrisMoody - 
//TMF Line to be uses with Histogram(Easier to Spot Divergences)
//Thresh Hold lines showing extremes - adjustable, histogram changes color based on threshold lines.
study("CM_Twiggs Money Flow", shorttitle="CM_TMF", overlay=false)
length = input( 21, " TMF Period")
sh = input(true, title="Show Histogram?")
sl = input(true, title="Show TMF Line?")
stl = input(true, title="Use Threshold Lines Color Change?")
sw = input(false, title="If Not Using Threshold Lines Color Change Change Below Values to 0")
upper_thresh = input(1, minval=0, title="UpperThreshold -- X .1 so 1 = .1")
lower_thresh = input(-1, minval=-3, title="Lower Threshold -- X .1 so -1 = -.1")

WiMA(src, length) => 
    MA_s=(src + nz(MA_s[1] * (length-1)))/length
    MA_s
  
upper_threshold = upper_thresh * .1
lower_threshold = lower_thresh * .1

tr_h=max(close[1],high)
tr_l=min(close[1],low)
tr_c=tr_h-tr_l
adv=volume*((close-tr_l)-(tr_h-close))/ iff(tr_c==0,9999999,tr_c)
wv=volume+(volume[1]*0)
wmV= WiMA(wv,length)
wmA= WiMA(adv,length)
tmf= iff(wmV==0,0,wmA/wmV)

c = stl and tmf >= upper_threshold ? lime : stl and tmf < lower_threshold ? red : yellow

plot(sh and tmf ? tmf : na, title="Twiggs Money Flow Histogram", style=histogram, linewidth=3, color=c)
plot(sl and sma(tmf, 1) ? sma(tmf, 1) : na, title="Twiggs Money Flow Line", style=line, linewidth=4, color=white)
hline(0, title="0 Line", color=silver, linestyle=solid, linewidth=3)
plot(stl and upper_threshold ? upper_threshold : na, title="Upper Threshold", style=line, linewidth=3, color=green)
plot(stl and lower_threshold ? lower_threshold : na, title="Lower Threshold", style=line, linewidth=3, color=maroon)