Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator("Study Hurst Exponent Forum Qta", overlay = false, precision = 6)
- length = input(64, title = "Hurst Exp Length")
- pnl = close / close[1] - 1
- mean_pnl = math.sum(pnl, length) / length
- cum = 0.0
- cum_min = 9999999.0
- cum_max = -9999999.0
- for i = 0 to length - 1
- cum := cum + pnl[i] - mean_pnl
- cum_min := math.min(cum_min, cum)
- cum_max := math.max(cum_max, cum)
- dev_sum = 0.0
- for i = 0 to length - 1
- dev_sum := dev_sum + (pnl[i] - mean_pnl) * (pnl[i] - mean_pnl)
- sd = math.sqrt(dev_sum / (length - 1))
- rs = (cum_max - cum_min) / sd
- hurstexp = math.log(rs) / math.log(length)
- plot(hurstexp, color = #247352, linewidth = 2, title = "HurstExponent")
- plot(0.5, color = color.gray, linewidth = 1, title = "")
Add Comment
Please, Sign In to add comment