2

I'm trying to convert this indicator to run on TradingView:

https://www.mql5.com/en/market/product/14320#description

The calculation seems straightforward but I'm getting really absurd numbers from this calculation. The steps for calculation are clearly shown on the image below:

enter image description here

Here's what I do to find the correct sin value of the angle "a":

  1. Find the close of the bar that the latest fractal appears on
  2. Find the close of the latest bar (3rd bar from the fractal in the picture)
  3. Subtract close of the fractal bar from the close of the latest bar, this gives us the value "b"
  4. The latest bar is 3 bars away from the fractal bar, this gives us the value "h"
  5. To find the value "c", do a basic hypotenuse calculation thus c = SQRT(h^2 + b^2)
  6. SinFractal = 100 * (b / c)

This should do the trick but I'm getting very small numbers and the graph I draw on TradingView is hugely different from what I see on MetaTrader.

Any ideas about what I'm doing wrong here?

PineCoders-LucF
  • 8,288
  • 2
  • 12
  • 21
Élodie Petit
  • 5,774
  • 6
  • 50
  • 88
  • Welcome, and where is some MCVE-code altogether with some unit-test data and expected results? – user3666197 Mar 29 '18 at 20:07
  • Please show the code you have tried to use. Also, I hope you are aware that TV pine-script *variables* are vector based and thus you can't just get "one" variable value, except as for a UI input parameter. Unfortunately! So using any kind of normal x-y coordinate system to do calculations are very tricky, if not often impossible. I'd suggest you raise the issue with the TV developer people. – not2qubit Apr 29 '18 at 18:36

0 Answers0