Maurizio-Ciullo

Hurst Exponent Forum Qta

Jun 17th, 2023 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@version=5
  2. indicator("Study Hurst Exponent Forum Qta", overlay = false, precision = 6)
  3.  
  4. length  = input(64,  title = "Hurst Exp Length")
  5.  
  6. pnl = close / close[1] - 1
  7. mean_pnl = math.sum(pnl, length) / length
  8. cum = 0.0
  9. cum_min = 9999999.0
  10. cum_max = -9999999.0
  11.  
  12. for i = 0 to length - 1
  13.     cum  := cum + pnl[i] - mean_pnl
  14.     cum_min := math.min(cum_min, cum)
  15.     cum_max := math.max(cum_max, cum)
  16.  
  17. dev_sum = 0.0
  18.  
  19. for i = 0 to length - 1
  20.     dev_sum := dev_sum + (pnl[i] - mean_pnl) * (pnl[i] - mean_pnl)
  21.  
  22. sd = math.sqrt(dev_sum / (length - 1))
  23. rs = (cum_max - cum_min) / sd
  24. hurstexp = math.log(rs) / math.log(length)
  25.  
  26. plot(hurstexp, color = #247352,  linewidth = 2, title = "HurstExponent")
  27. plot(0.5,  color = color.gray, linewidth = 1, title = "")  
Add Comment
Please, Sign In to add comment