RicardoSantos

[RS]Function - Minkowski_distance

copy pasted description..
Minkowski distance is a metric in a normed vector space. Minkowski distance is used for distance similarity of vector. Given two or more vectors, find distance similarity of these vectors.
Release Notes: added more examples and a bug with valuewhen().
Release Notes: fixed, now it calculates accurately.
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.

Want to use this script on a chart?

Comments

Yes this is super interesting! Does anyone know why this maxes and reverses most often when prices are hitting lows? On equities anyway... I have yet to study this on futures/commodities
Reply
RicardoSantos TransitMan
@TransitMan,
h = valuewhen(high >= highest(10), high, 0)
b = valuewhen(high >= highest(10), n, 0)
mdn = f_minkowski_distance(h, b, close, n, p)

its checking the distance to the last high/pivot/resistance point
Reply
TransitMan RicardoSantos
@RicardoSantos, Thanks Ricardo I can't thank you enough for sharing so much of your intelligence, hard work and creative talent which reminds me I need to share some funds to you and others who I have come to rely on Do you have pay-pal share link?
Reply
Interesting! With EMA length = 2, the curve is very close to historical volatility. When replacing the EMA expression with close, it seems to be virtually the same curve (but different values of course).
Reply
Epi_ Epi_
"Replacing the EMA expression with close(t-1)..." (TV seems to filter the 1 in brackets that I typed.)
Reply
@Epi_, Yep, I was playing with values 8 and 55 and it looks like it can be a useful volatility indicator.
Reply
This is interesting, thanks for sharing!
Reply