Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. <script>
  2. // Grin
  3.  
  4. // Adds all necessary stuff for you.
  5. import Overlay from './overlay.js'
  6.  
  7. export default {
  8. name: 'Grin',
  9. mixins: [Overlay],
  10. methods: {
  11. // Here goes your code. You are provided with:
  12. // { All stuff is reactive }
  13. // $props.layout -> positions of all chart elements +
  14. // some helper functions (see layout_fn.js)
  15. // $props.interval -> candlestick time interval
  16. // $props.sub -> current subset of candlestick data
  17. // $props.data -> your indicator's data subset.
  18. // Comes "as is", should have the following format:
  19. // [[<timestamp>, ... ], ... ]
  20. // $props.colors -> colors (see TradingVue.vue)
  21. // $props.cursor -> current position of crosshair
  22. // $props.settings -> indicator custom settings
  23. // E.g. colors, line thickness, etc. You define it.
  24. // ~
  25. // Finally, let's make the canvas dirty!
  26. draw(ctx) {
  27. const l = this.$props.layout
  28. const c = { x : l.width / 2, y : l.height / 2 }
  29. ctx.lineWidth = 3
  30. ctx.strokeStyle = ctx.fillStyle = 'yellow'
  31. ctx.beginPath()
  32. ctx.arc(c.x, c.y, 50, 0, Math.PI * 2, true) // Outer circle
  33. ctx.fill()
  34. ctx.stroke()
  35. ctx.beginPath()
  36. ctx.strokeStyle = 'black'
  37. ctx.moveTo(c.x + 35, c.y)
  38. ctx.arc(c.x, c.y, 35, 0, Math.PI , false) // Mouth (clockwise)
  39. ctx.moveTo(c.x - 10, c.y - 10)
  40. ctx.fillStyle = 'yellow'
  41. ctx.arc(c.x - 15, c.y - 10, 5, 0, Math.PI * 2, true) // Left eye
  42. ctx.fill()
  43. ctx.moveTo(c.x + 20, c.y - 10)
  44. ctx.arc(c.x + 15, c.y - 10, 5, 0, Math.PI * 2, true) // Right eye
  45. ctx.fill()
  46. ctx.stroke()
  47. },
  48.  
  49. // For all data with these types overlay will be
  50. // added to the renderer list. And '$props.data'
  51. // will have the corresponding values. If you want to
  52. // redefine the default behviour for a prticular
  53. // indicator (let's say EMA),
  54. // just create a new overlay with the same type:
  55. // e.g. use_for() { return ['EMA'] }.
  56. use_for() { return ['GRIN'] }
  57. },
  58. data() {
  59. // Define internal setting & constants here
  60. return {}
  61. }
  62.  
  63. }
  64. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement