Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2018
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. //@version=3
  2. //author=[Cyrus c|:D]
  3. study(title="Accumulation/Distribution Money Flow [c|:D]", shorttitle="[ADMF]", precision=0)
  4.  
  5. // inputs
  6. mas = input(title="Aggregation", defval="EMA", options=["SMA", "EMA", "Sum"])
  7. len = input(27, minval=1, title="Moving Average Length") // EMA27 = SMMA/RMA14 ~ lunar month
  8. pEnable = input(true, title="Factor price (money flow)")
  9. src = input(close, title="Source")
  10. norm = input(title="Normalize by", defval="Spread", options=["Disable", "Spread", "Previous Bar Price"])
  11. ve = input(5.0, minval=0, title="Volume Exponent (10+ increases and 10- decreases volume factor)")
  12. weight = input(0.0, minval=0, maxval=10.0, title="Wick Weight")
  13. tvf = input(false, title="Enable Volume Aggregation (in Sum mode, gray line shows OBV)")
  14.  
  15. // calculations
  16. eps = 0.00000001
  17. trl = min(low,close[1]), trh = max(high,close[1]) // 'True Range' fixes issues caused by gaps in price
  18. adr = weight*(2*close-(trh+trl))/10.0 + (1-weight/10.0)*change(src)
  19. adr := norm=="Disable" ? adr : adr/(norm=="Spread" ? nz(tr(true),eps) : nz(src[1],eps))
  20. v = pow(volume,ve/10)*(pEnable ? src : 1)
  21. spv = sign(adr)*v
  22. sad = adr*v
  23.  
  24. // aggregation
  25. maSV = not tvf ? na : mas=="SMA" ? sma(spv,len) : mas=="EMA" ? ema(spv,len) : cum(spv)
  26. maSAD = mas=="SMA" ? sma(sad,len) : mas=="EMA" ? ema(sad,len) : cum(sad)
  27.  
  28. // plot
  29. plot(maSAD, style=line, color=#4477ffff, title="Accumulation/Distribution")
  30. plot(maSV, style=line , color=#888888ff, title="Volume")
  31. plot(mas!="Sum" ? 0 : na, color=#88888866, title="Middle Line")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement