Mis à jour
Moon Phases Strategy 2015 till 2021

Moon Phases Strategy
Thank you to Author: Dustin Drummond for allowing me to use his Moon Phase strategy code and modify it. I wanted to test out the accuracy of the moon phase. And I could not have done it without his code
It was created to test the Moon Phase theory compared to just a buy and hold strategy.
It buys on full Moon and sells on the new moon. I also have added the ability to add stop loss and target profit if anyone wants to tinker with it. This strategy uses hard-coded dates from 1/1/2015 until 12/31/2021 only! Any dates outside of that range need to be added manually in the code or it will not work.
I may or may not update this so please don't be upset if it stops working after 12/31/2021.
Feel free to use any part of this code and please let me know if you can improve on this strategy.
Result:
50% accurate using data from 2015 till today.
I find a buy and hold strategy to have outperformed the moon phase.
It does have its value. It might be used as a confluence with other established indicators.
Thank you to Author: Dustin Drummond for allowing me to use his Moon Phase strategy code and modify it. I wanted to test out the accuracy of the moon phase. And I could not have done it without his code
It was created to test the Moon Phase theory compared to just a buy and hold strategy.
It buys on full Moon and sells on the new moon. I also have added the ability to add stop loss and target profit if anyone wants to tinker with it. This strategy uses hard-coded dates from 1/1/2015 until 12/31/2021 only! Any dates outside of that range need to be added manually in the code or it will not work.
I may or may not update this so please don't be upset if it stops working after 12/31/2021.
Feel free to use any part of this code and please let me know if you can improve on this strategy.
Result:
50% accurate using data from 2015 till today.
I find a buy and hold strategy to have outperformed the moon phase.
It does have its value. It might be used as a confluence with other established indicators.
Notes de version
Deleted commented out codeNotes de version
Updated description textNotes de version
# Moon Phases Strategy — Full Moon Buy / New Moon Sell**An astronomy-based trading strategy exploring the relationship between lunar cycles and financial market performance. Built with Pine Script v6, featuring calculated lunar events and backtesting support through 2040.**
## Overview
The Moon Phases Strategy is a systematic, long-only trading model designed to investigate whether lunar cycles exhibit any measurable relationship with financial market behaviour. This is only for research purpose. This is not any financial advice or to be used for any real financial usuage.
The strategy follows a straightforward hypothesis: **buy following a Full Moon and sell following a New Moon.**
Rather than relying on traditional technical indicators, price patterns, or momentum oscillators, this strategy uses astronomical lunar events to determine its trading signals.
Its primary purpose is to provide a consistent, reproducible framework for testing the lunar-cycle hypothesis against conventional approaches such as buy-and-hold.
## Trading Logic
The strategy operates using two principal signals:
**Full Moon — BUY**
When a Full Moon occurs, the strategy generates a long-entry signal, provided no position is currently open.
**New Moon — SELL**
When a New Moon occurs, the strategy generates a signal to close the existing long position.
After selling, the strategy remains out of the market until the next Full Moon entry signal.
The strategy does not open short positions, use automatic reversals, or pyramid multiple entries.
The complete trading sequence is:
**Full Moon → Buy → Hold → New Moon → Sell → Remain in Cash → Repeat**
## Astronomical Calculation
Unlike earlier implementations that relied on manually entered lunar dates, this version calculates Full Moon and New Moon events algorithmically.
The calculations are based on the lunar-phase algorithms presented in Jean Meeus's *Astronomical Algorithms*, Chapter 49, incorporating an approximation for the difference between Terrestrial Time (TT) and Universal Time (UT).
This eliminates the need to manually update lunar calendars each year.
The strategy is configured for testing from **2015 through 2040**, with adjustable backtesting dates. Please note there may be mistakes.
Lunar event times are calculated rather than retrieved from an external astronomical feed and should therefore be treated as approximations.
## Strategy Features
- **Pine Script v6:**
- **Dynamic Moon Calculations:** No manually maintained annual date lists.
- **Long-Only Trading:** Buys at Full Moon signals and sells at New Moon signals.
- **Backtesting Through 2040:** Configurable start and end dates.
- **Optional Chart Markers:** Visual identification of lunar signals.
- **Controlled Position Sizing:**
- **No Short Selling:** Designed for straightforward long-only market participation.
- **No Built-In Stop-Loss or Take-Profit:** Positions are exited through lunar signals or at the configured backtest end.
- **Non-Pyramiding Execution:** Only one long position can be held at a time.
## Execution and Backtesting
Signals are confirmed after the calculated lunar event has occurred.
Orders are generated at the close of the first qualifying chart candle and, under the default TradingView broker-emulator settings, are filled at the opening of the following candle.
Consequently, execution does not necessarily coincide with the precise astronomical event time.
For initial analysis, standard daily candlestick charts are recommended.
Results depend on the selected instrument, timeframe, available historical data, transaction costs, slippage, and TradingView's execution assumptions.
Users should configure realistic trading costs and compare strategy performance against a buy-and-hold benchmark over equivalent testing periods.
## Research Purpose
This strategy is intended to explore questions such as:
- Do market returns differ between the Full Moon and New Moon periods?
- Does lunar-cycle-based market exposure produce a measurable advantage over buy-and-hold?
- Are observed results consistent across different assets and market conditions?
- Do any apparent historical relationships remain significant after trading costs and out-of-sample testing?
The strategy does not assume that lunar phases cause market movements. Any observed correlation should be evaluated critically, including the possibility of coincidence, regime dependence, and statistical noise. This is not for financial advice. This is Not to be used with any actual money or any trading.
## Limitations and Risk Disclosure
Lunar phases are predictable astronomical events, but financial market prices are not.
A predictable signal schedule does not establish a profitable trading advantage.
The strategy does not incorporate trend confirmation, volatility filters, fundamental analysis, or protective stop-loss orders.
Significant losses remain possible, including during the holding period between Full Moon and New Moon signals.
Historical backtest performance does not guarantee future results. This script is provided for research, education, and strategy evaluation, not as investment advice.
## Credits and Attribution
This implementation builds upon the original Moon Phases Strategy published by **Joy Bangla**, which credited **Dustin Drummond** for the underlying moon-phase strategy work.
Dustin Drummond: tradingview.com/u/Dustin_D_RLT/
The updated implementation replaces the original hard-coded lunar dates with astronomical calculations and simplifies execution to a long-only buy/sell model.
Original and modified source code is distributed under the **Mozilla Public License 2.0 (MPL 2.0)**.
Astronomical methodology references:
Jean Meeus — *Astronomical Algorithms*, Chapter 49.
NASA / Espenak and Meeus — Delta T approximations.
---
**The objective is not to predict markets through astronomy, but to test whether a simple, objectively defined lunar-cycle trading rule demonstrates meaningful behaviour across different market environments.**
Not built for dopamine. Built for positioning.
Private access to ALADDIN / Vector Fusion - $549 lifetime. Limited release.
Private access to ALADDIN / Vector Fusion - $549 lifetime. Limited release.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Not built for dopamine. Built for positioning.
Private access to ALADDIN / Vector Fusion - $549 lifetime. Limited release.
Private access to ALADDIN / Vector Fusion - $549 lifetime. Limited release.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.