[PX] Moon Phase

Hello guys,

while scrolling through the public library, I was surprised that there was no Open-Source version of the Moon Phase indicator. All moon phase indicators in the public library were either protected or not exactly what I was looking for. There is a built-in "Moon Phase" indicator, but even for this one, we can't access its source code.
Therefore, I started searching for an algorithm that I could implement into PineScript.

So here we go, an Open-Source Moon Phase indicator. It comes with the option to color the background based on the recent moon. Compared to the built-in indicator, the moon is slightly shifted, because it is centered on the candle and not plotted between two candles like the built-in indicator is doing it.

Feel free to use the indicator for your analysis or build on top of it in an open-source fashion.

Happy trading,
paaax :)

Reference: This indicator is a converted and simplified version of the original javascript algorithm, which can be found here.
Ta bort från favoritskript Lägg till som favoritskript - Custom indicator development


I'm not a coder this help me a lot and Thank you for your hard work!
+3 Svara

how do I encode this indicator in trading view.



Thanks for sharing!!
Brilliant! I notice the phase timings differ to the built-in indicator - is there a reason for this? many thanks.
Thank you very much. I was also unable to edit the source code for the built-in TradingView Moon Phases indicator. Is it possible to plot the upcoming moons on the chart as opposed to only plotting them when they happen? Eg. Plot moons for a particular period of time ahead, lets say a month.
sam20000 DougQuaid
@DougQuaid, Hey Doug, did you manage to plot the moon phases into the future?
DougQuaid sam20000
@sam20000, No I didn't, unfortunately, as I haven't figured it out yet. @paaax - Any thoughts on my original comment above?
+1 Svara
mxvin DougQuaid
@DougQuaid, Actually it's quite easy to make phases ahead current date, You might want to check my modified script :)
+2 Svara
Hi @mxvin, thanks for the response! I just re-added the script however where is it that I can plot the phases ahead of the current date? There are no options to do that in the config window.
mxvin DougQuaid
@DougQuaid, Maybe you still use original paaax script, check again as I'm not changing the indicator name. and you can change how many (+) days after today you want phases shows on indicator settings -> Input. hope it helps :)
Hem Aktie-screener Forex-screener Krypto-screener Ekonomisk kalender Hur det fungerar Diagramfunktioner Priser Tipsa en vän Ordningsregler Hjälpcenter Webbsidor och mäklarlösningar Widgets Diagramlösningar Lightweight Charting Library Blogg och nyheter Twitter
Profil Profilinställningar Konto och fakturering Hänvisade vänner Mynt Mina kölappar Hjälpcenter Publicerade idéer Följare Följer Privata meddelanden Chatt Logga ut