xmd79

Astro: Planetary Aspects v2.0

Oct 11th, 2023
468
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.91 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © BarefootJoey
  3.  
  4. // With much respect to @BarefootJoey, the following small changes have been implemented by @Yevolution:
  5. // 1. Overlay the indicator plot on top of the main chart, with the indicator's scale placed on the left - I found it easier to spot price reactions at a given planetary aspect vs seeing the plot in a separate frame
  6. // 2. Add options to plot a vertical bar for every occurrence of chosen aspects
  7. // 3. The "Precision" setting changes the width of each plotted bar to shade in the calculated window of time while the aspect is in progress.
  8. // - eg. 1: if "Precision" is set to 3 degrees, then the "Trine" aspect bar will appear when the aspect is between 117 & 123 degrees
  9. // - eg. 2: if "Precision" is set to 15 degrees, then the "Opposition" aspect bar will appear when the aspect is between 165 & 195 degrees
  10. // - eg. 3: if "Precision" is set to 6 degrees, then the "Conjunction" aspect bar will appear when the aspect is between 0 & 6 degrees (though technically the aspect moves from 253 to 0 to 6 degrees covering a span of 12 degrees)
  11. // Additional comments for specific functions have been placed above the function in question
  12.  
  13. // ██████████████████████████████████████████████████████████████████████ _____ __ _ _______ _____ _______ _______ _______
  14. // █▄─▄─▀██▀▄─██▄─▄▄▀█▄─▄▄─█▄─▄▄─█─▄▄─█─▄▄─█─▄─▄─███▄─▄█─▄▄─█▄─▄▄─█▄─█─▄█ | | \ | |______ |_____] |_____| | |______
  15. // ██─▄─▀██─▀─███─▄─▄██─▄█▀██─▄███─██─█─██─███─███─▄█─██─██─██─▄█▀██▄─▄██ __|__ | \_| ______| | | | |_____ |______
  16. // █▄▄▄▄██▄▄█▄▄█▄▄█▄▄█▄▄▄▄▄█▄▄▄███▄▄▄▄█▄▄▄▄██▄▄▄██▄▄▄███▄▄▄▄█▄▄▄▄▄██▄▄▄██
  17.  
  18. //@version=5
  19. indicator("Astro: Planetary Aspects v2.0", overlay=true, scale=scale.left, max_boxes_count = 500)
  20.  
  21. import BarefootJoey/AstroLib/1 as AL
  22.  
  23. interplanet = input.bool(false, "Interplanetary aspects?", tooltip="Leave this box unchecked for single planet aspects.")
  24. planet1_in = input.string("☿ Mercury", "Which planets?", options=["☉︎ Sun", "☽︎ Moon", "☿ Mercury", "♀ Venus", "🜨 Earth", "♂ Mars", "♃ Jupiter", "♄ Saturn", "⛢ Uranus", "♆ Neptune", "♇ Pluto"], inline="3")
  25. planet2_in = input.string("♂ Mars", " ", options=["☉︎ Sun", "☽︎ Moon", "☿ Mercury", "♀ Venus", "🜨 Earth", "♂ Mars", "♃ Jupiter", "♄ Saturn", "⛢ Uranus", "♆ Neptune", "♇ Pluto"], inline="3")
  26. precision = input.float(6.0, "Aspect Precision (+/- °)", minval=0, maxval=15)
  27. showlast = input.int(1000, "Show last?", minval=1, tooltip="Number of historical plots to display. The fewer plots, the faster the load time (especially on loweer timeframes).")
  28. col_asp = input.color(color.white, "Aspect & Info Color")
  29. iTxtSize=input.string("Normal", title="Text & Symbol Size", options=["Auto", "Tiny", "Small", "Normal", "Large"], inline="1")
  30. vTxtSize=iTxtSize == "Auto" ? size.auto : iTxtSize == "Tiny" ? size.tiny : iTxtSize == "Small" ? size.small : iTxtSize == "Normal" ? size.normal : iTxtSize == "Large" ? size.large : size.small
  31. position = input.string(position.top_center, "Aspect Info Position", [position.top_center, position.top_right, position.middle_right, position.bottom_right, position.bottom_center, position.bottom_left, position.middle_left, position.top_left])
  32.  
  33. //// The "Time Machine" function is no longer necessary and has been effectively replaced by drawing vertical bars at each occurence of an aspect. To re-enable it, simply uncomment lines #36 & #37 and comment lines #38 & #39. @Yevolution ////
  34.  
  35. grtm = "🕜 Time Machine 🕜"
  36. //gsd = input.bool(false, "Activate Time Machine", group=grtm)
  37. //sdms = input.time(timestamp("2022-04-20T00:00:00"), "Select Date", group=grtm)
  38. gsd = false
  39. sdms = timestamp("2022-04-20T00:00:00")
  40. gt = gsd ? sdms : time
  41.  
  42. //// The latitude/longitude variables do not appear to have any effect, however I've left them enabled in order not to break anything. @Yevolution ////
  43.  
  44. grol = "🔭 Observer Location 🔭"
  45. htz = input.float(0, "Hour", step=0.5, inline="2", group=grol)
  46. mtz = input.int(0, "Minute", minval=0, maxval=45, inline="2", group=grol)
  47. tz = htz + math.round(mtz / 60, 4)
  48. latitude = input.float(0, "Latitude", inline="1", group=grol)
  49. longitude = input.float(0, "Longitude", inline="1", group=grol)
  50. geo = input.bool(false, "Geocentric?", tooltip="Leave this box unchecked for heliocentric.", group=grol)
  51. geoout = geo ? 1 : 0
  52.  
  53. day = AL.J2000(AL.JDN(gt, 0, tz))
  54. dayr = AL.J2000(AL.JDN(gt, 1, tz))
  55.  
  56. if interplanet and planet1_in == planet2_in
  57. runtime.error("Planet cannot aspect itself. Please select 2 different planets for interplanetary analysis.")
  58.  
  59. long1_out = planet1_in == "☉︎ Sun" ? AL.getsun(geoout, day, dayr, latitude, longitude, tz) : planet1_in == "☽︎ Moon" ? AL.getmoon(geoout, day, dayr, latitude, longitude) : planet1_in == "☿ Mercury" ? AL.getplanet(1, geoout, day, dayr, latitude, longitude, tz) : planet1_in == "♀ Venus" ? AL.getplanet(2, geoout, day, dayr, latitude, longitude, tz) : planet1_in == "🜨 Earth" ? AL.getplanet(3, geoout, day, dayr, latitude, longitude, tz) : planet1_in == "♂ Mars" ? AL.getplanet(4, geoout, day, dayr, latitude, longitude, tz) : planet1_in == "♃ Jupiter" ? AL.getplanet(5, geoout, day, dayr, latitude, longitude, tz) : planet1_in == "♄ Saturn" ? AL.getplanet(6, geoout, day, dayr, latitude, longitude, tz) : planet1_in == "⛢ Uranus" ? AL.getplanet(7, geoout, day, dayr, latitude, longitude, tz) : planet1_in == "♆ Neptune" ? AL.getplanet(8, geoout, day, dayr, latitude, longitude, tz) : planet1_in == "♇ Pluto" ? AL.getplanet(9, geoout, day, dayr, latitude, longitude, tz) : na
  60. long2_out = planet2_in == "☉︎ Sun" ? AL.getsun(geoout, day, dayr, latitude, longitude, tz) : planet2_in == "☽︎ Moon" ? AL.getmoon(geoout, day, dayr, latitude, longitude) : planet2_in == "☿ Mercury" ? AL.getplanet(1, geoout, day, dayr, latitude, longitude, tz) : planet2_in == "♀ Venus" ? AL.getplanet(2, geoout, day, dayr, latitude, longitude, tz) : planet2_in == "🜨 Earth" ? AL.getplanet(3, geoout, day, dayr, latitude, longitude, tz) : planet2_in == "♂ Mars" ? AL.getplanet(4, geoout, day, dayr, latitude, longitude, tz) : planet2_in == "♃ Jupiter" ? AL.getplanet(5, geoout, day, dayr, latitude, longitude, tz) : planet2_in == "♄ Saturn" ? AL.getplanet(6, geoout, day, dayr, latitude, longitude, tz) : planet2_in == "⛢ Uranus" ? AL.getplanet(7, geoout, day, dayr, latitude, longitude, tz) : planet2_in == "♆ Neptune" ? AL.getplanet(8, geoout, day, dayr, latitude, longitude, tz) : planet2_in == "♇ Pluto" ? AL.getplanet(9, geoout, day, dayr, latitude, longitude, tz) : na
  61.  
  62. p1p2=math.abs(AL.degtolowest180(AL.AngToCirc(long1_out - (interplanet?long2_out:0))))
  63. plot(p1p2, color=col_asp, linewidth=2, show_last=showlast)
  64.  
  65. htrans=66
  66. hline(0, color=color.new(color.red, htrans))
  67. hline(30, color=color.new(color.orange, htrans))
  68. hline(60, color=color.new(color.yellow, htrans))
  69. hline(90, color=color.new(color.green, htrans))
  70. hline(120, color=color.new(color.aqua, htrans))
  71. hline(150, color=color.new(color.navy, htrans))
  72. hline(180, color=color.new(color.purple, htrans))
  73.  
  74. var label conj = na
  75. var label ssex = na
  76. var label sext = na
  77. var label squa = na
  78. var label trin = na
  79. var label inco = na
  80. var label oppo = na
  81.  
  82. if barstate.islast
  83. conj := label.new(bar_index, y=0, text="☌", size=vTxtSize, style=label.style_label_left, color=color.new(color.white,100), textcolor=color.new(color.red,0), tooltip="☌ Conjunction 0°\n" + "")
  84. label.delete(conj[1])
  85. ssex := label.new(bar_index, y=30, text="⊻", size=vTxtSize, style=label.style_label_left, color=color.new(color.white,100), textcolor=color.new(color.orange,0), tooltip="⊻ Semi Sextile 30°\n" + "")
  86. label.delete(ssex[1])
  87. sext := label.new(bar_index, y=60, text="🞶", size=vTxtSize, style=label.style_label_left, color=color.new(color.white,100), textcolor=color.new(color.yellow,0), tooltip="🞶 Sextile 60°\n" + "")
  88. label.delete(sext[1])
  89. squa := label.new(bar_index, y=90, text="□", size=vTxtSize, style=label.style_label_left, color=color.new(color.white,100), textcolor=color.new(color.green,0), tooltip="□ Square 90°\n" + "")
  90. label.delete(squa[1])
  91. trin := label.new(bar_index, y=120, text="△", size=vTxtSize, style=label.style_label_left, color=color.new(color.white,100), textcolor=color.new(color.aqua,0), tooltip="△ Trine 120°\n" + "")
  92. label.delete(trin[1])
  93. inco := label.new(bar_index, y=150, text="⊼", size=vTxtSize, style=label.style_label_left, color=color.new(color.white,100), textcolor=color.new(color.navy,0), tooltip="⊼ Inconjunct 150°\n" + "")
  94. label.delete(inco[1])
  95. oppo := label.new(bar_index, y=180, text="☍", size=vTxtSize, style=label.style_label_left, color=color.new(color.white,100), textcolor=color.new(color.purple,0), tooltip="☍ Opposition 180°\n" + "")
  96. label.delete(oppo[1])
  97.  
  98. retro_tt(deg) => deg > deg[1] ? "" : " ℞"
  99. retro_tt_out = retro_tt(AL.AngToCirc(long1_out - (interplanet?long2_out:0)))
  100.  
  101. var table Info = na
  102. table.delete(Info)
  103. Info := table.new(position, 1, 1)
  104. if barstate.islast
  105. table.cell(Info, 0, 0,
  106. text = planet1_in + (interplanet?" ∡ "+planet2_in:"") + retro_tt_out,
  107. text_size = vTxtSize,
  108. text_color = color.new(col_asp,0),
  109. tooltip = AL.aspectsignprecisionV2ext(p1p2, precision) + "°\nPrecision: +/- " + str.tostring(precision) + "°")
  110.  
  111.  
  112. //// Vertical bars for Aspect time windows by @Yevolution ////
  113.  
  114. // Inputs to allow (de)selection of individual aspects
  115.  
  116. grvb = "Aspects marked with a vertical Bar:"
  117. ConjunctVertBar = input.bool(true, "Conjunction", group = grvb)
  118. SemiSextVertBar = input.bool(true, "Semi Sextile", group = grvb)
  119. SextVertBar = input.bool(true, "Sextile", group = grvb)
  120. SquareVertBar = input.bool(true, "Square", group = grvb)
  121. TrineVertBar = input.bool(true, "Trine", group = grvb)
  122. InConjunctVertBar = input.bool(true, "Inconjunct", group = grvb)
  123. OppositVertBar = input.bool(true, "Opposition", group = grvb)
  124.  
  125. // Logic to determine if an aspect is currently in progress
  126.  
  127. conjunctionActive = p1p2 <= (0 + precision)
  128. semiSextActive = p1p2 >= (30 - precision) and p1p2 <= (30 + precision)
  129. sextActive = p1p2 >= (60 - precision) and p1p2 <= (60 + precision)
  130. squareActive = p1p2 >= (90 - precision) and p1p2 <= (90 + precision)
  131. trineActive = p1p2 >= (120 - precision) and p1p2 <= (120 + precision)
  132. inConjunctActive = p1p2 >= (150 - precision) and p1p2 <= (150 + precision)
  133. oppositionActive = p1p2 >= (180 - precision)
  134.  
  135. // Plot vertical bars on chart
  136.  
  137. line1 = plot(conjunctionActive and ConjunctVertBar ? 0 : na, color = color.new(color.red, 100))
  138. line2 = plot(conjunctionActive and ConjunctVertBar ? 180 : na, color = color.new(color.red, 100))
  139.  
  140. line3 = plot(semiSextActive and SemiSextVertBar ? 0 : na, color = color.new(color.orange, 100))
  141. line4 = plot(semiSextActive and SemiSextVertBar ? 180 : na, color = color.new(color.orange, 100))
  142.  
  143. line5 = plot(sextActive and SextVertBar ? 0 : na, color = color.new(color.yellow, 100))
  144. line6 = plot(sextActive and SextVertBar ? 180 : na, color = color.new(color.yellow, 100))
  145.  
  146. line7 = plot(squareActive and SquareVertBar ? 0 : na, color = color.new(color.green, 100))
  147. line8 = plot(squareActive and SquareVertBar ? 180 : na, color = color.new(color.green, 100))
  148.  
  149. line9 = plot(trineActive and TrineVertBar ? 0 : na, color = color.new(color.aqua, 100))
  150. line10 = plot(trineActive and TrineVertBar ? 180 : na, color = color.new(color.aqua, 100))
  151.  
  152. line11 = plot(inConjunctActive and InConjunctVertBar ? 0 : na, color = color.new(color.navy, 100))
  153. line12 = plot(inConjunctActive and InConjunctVertBar ? 180 : na, color = color.new(color.navy, 100))
  154.  
  155. line13 = plot(oppositionActive and OppositVertBar ? 0 : na, color = color.new(color.purple, 100))
  156. line14 = plot(oppositionActive and OppositVertBar ? 180 : na, color = color.new(color.purple, 100))
  157.  
  158.  
  159. fill(line1, line2, color=color.new(color.red, 75))
  160. fill(line3, line4, color=color.new(color.orange, 75))
  161. fill(line5, line6, color=color.new(color.yellow, 75))
  162. fill(line7, line8, color=color.new(color.green, 75))
  163. fill(line9, line10, color=color.new(color.aqua, 75))
  164. fill(line11, line12, color=color.new(color.navy, 75))
  165. fill(line13, line14, color=color.new(color.purple, 75))
  166.  
  167.  
  168. // EoS made w/ ❤ by @BarefootJoey ✌💗📈
  169. // Respectfully updated with additional functions by @Yevolution
Advertisement
Comments
  • # text 0.13 KB | 0 0
    1. i downloaded all types of premium tradingview indicators codes available on telegram - https://t.me/tradingview_premium_indicator
Add Comment
Please, Sign In to add comment