xmd79

Circle Plot

May 23rd, 2023
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. //@version=5
  2. indicator("Circle Plot", overlay=true)
  3.  
  4. // Define constants
  5. pi = 3.14159
  6.  
  7. // Calculate number of points on the unit circle
  8. numPoints = 360
  9.  
  10. // Initialize arrays to store x and y coordinates
  11. var float[] circle_x = array.new_float(numPoints, na)
  12. var float[] circle_y = array.new_float(numPoints, na)
  13.  
  14. // Calculate x and y coordinates of the unit circle
  15. for i = 0 to numPoints - 1
  16. angle = 2 * pi * i / numPoints
  17. array.set(circle_x, i, close + math.cos(angle))
  18. array.set(circle_y, i, close + math.sin(angle))
  19.  
  20. // Plotting the circle
  21. plot(array.get(circle_x, bar_index % numPoints), "Circle X", color=color.blue, linewidth=2)
  22. plot(array.get(circle_y, bar_index % numPoints), "Circle Y", color=color.red, linewidth=2)
  23.  
Advertisement
Add Comment
Please, Sign In to add comment