Cosine distance and cosine similarity – library MetaTrader 5

function to calculate the cosine distance and the cosine similarity.

The cosine distance between 2 vectors A and B is : 

So 1-CosineSimilarity

And the cosine similarity is :

In simple terms :

  • the cosine of the angle between the 2 vectors
  • or , the dot product of the vectors divided by their magnitudes multiplied

Here is the simplest explanation (although his cos(45) is wrong) : 



📈 ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks
Alternative:   BBS_Histogram - indicator MetaTrader 5