Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Simple Moon Phases Strategy

A Pine Script v4 strategy with no technical-analysis calculation. It has 2 order rules and no entry of its own. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays no commission. It has no settings.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does Simple Moon Phases Strategy repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did Simple Moon Phases Strategy do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its entry conditions never all held on this data. It closed no trades on the other markets either. A backtest, not investment advice.
Can Simple Moon Phases Strategy be converted to Pine Script v5?
Not tested
The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
Does Simple Moon Phases Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Simple Moon Phases Strategy run in Zeal Terminal?
Yes
It compiles in 46 ms and runs 1,000 bars in 385 ms, in the browser.

BTCUSDT · 1D · default settings

  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (0)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$100,000$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 39) so the engine trades the way the script says.
Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
$0.00

One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

  • Note

    Uses an argument v6 removed

    when = on line 39, 41. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 44

    transp = on line 44. v5 folds the transparency into the colour with color.new(c, transp).

  • Note

    Uses long =, which v5 renamed line 39

    long = on line 39. v5 writes it as direction = strategy.long or strategy.short.

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • 2 strategy calls use the when = argument (line 39, 41). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 2: //@version=4 → //@version=5
  • Line 39: long = true → direction = strategy.long
  • Line 44: transp = 85 → color.new(backgroundColour, 85)
//This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/-//@version=4+//@version=5//Author: Dustin Drummond https://www.tradingview.com/u/Dustin_D_RLT/⋯//Entry Order-strategy.order("Full Moon Entry", long = true, when = (strategy.position_size <= 0 and entrySignal))+strategy.order("Full Moon Entry", direction = strategy.long, when = (strategy.position_size <= 0 and entrySignal))//Exit Order⋯backgroundColour = (strategy.position_size > 0) ? color.green : color.red-bgcolor(color=backgroundColour, transp=85)+bgcolor(color=color.new(backgroundColour, 85))

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 39: when = (strategy.position_size <= 0 and entrySignal) → if block
  • Line 41: when = exitSignal → if block
⋯//Entry Order-strategy.order("Full Moon Entry", direction = strategy.long, when = (strategy.position_size <= 0 and entrySignal))+if (strategy.position_size <= 0 and entrySignal)+    strategy.order("Full Moon Entry", direction = strategy.long)//Exit Order-strategy.close_all(when = exitSignal, comment = "New Moon Exit")+if exitSignal+    strategy.close_all(comment = "New Moon Exit")//Background fill⋯

Does it run in Pine Script v6?

Not tested

Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

//This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/-//@version=5+//@version=6//Author: Dustin Drummond https://www.tradingview.com/u/Dustin_D_RLT/⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

The script declares no settings.

What it calculates

No technical-analysis calculation: the script works on prices and settings directly.

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

fullMoon2015, newMoon2015, fullMoon2016, newMoon2016, fullMoon2017, newMoon2017, fullMoon2018, newMoon2018, fullMoon2019, newMoon2019, fullMoon2020, newMoon2020, fullMoon2021, newMoon2021fullMoon2015 · newMoon2…14 valuesexitSignalexitSignalconditionfullMoon, newMoonfullMoon · newMoon2 conditionsentrySignalentrySignalconditionbackgroundColourColourbackgroundColourorder:Full Moon Entryorder Full Moon Entrystrategy.orderclose_all:close_all strategy.close_allplotshape:33plotshapeplotshapeplotshape:34plotshapeplotshapebgcolor:44bgcolorbgcolor

Order rules

OrderFires whenBy defaultLine
order Full Moon Entry long(strategy.position_size <= 0 and entrySignal)On39
Close exitSignal(strategy.position_size >= 0 and newMoon)On41

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationcalc_on_every_tick = true. Live values can differ from history.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—0.0%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

Similar scripts

No other indicator or strategy here shares enough of its calculations.

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 46 msWith a workaround 1,000 bars in 385 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 39) so the engine trades the way the script says.

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

//This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0///@version=4//Author: Dustin Drummond https://www.tradingview.com/u/Dustin_D_RLT///Simple Moon Phases Strategy//This strategy is very basic and needs some filters to improve results. //It was created to test the Moon Phase theory compared to just a buy and hold strategy and it did not beat the buy and hold. //However, if you flip the entry and exit signals to the opposite signals it performs a lot worse, so there might be some validity to the Moon Phases having an effect on the markets.//I might try to add some filters and increase hold times with trailing stops in a separate version.//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.strategy(title="Simple Moon Phases Strategy", shorttitle = "Moon Phases", overlay = true, calc_on_every_tick=true, default_qty_value=100, initial_capital = 100000, default_qty_type=strategy.percent_of_equity, pyramiding = 0, process_orders_on_close=false)//Define Full Moons and New Moons per year (idetifies 1 day prior so order entry can be on open of next day)fullMoon2015 = year == 2015 and ((month == 1 and dayofmonth == 2) or (month == 2 and dayofmonth == 3) or (month == 3 and dayofmonth == 5) or (month == 4 and dayofmonth == 2) or (month == 5 and dayofmonth == 1) or (month == 6 and dayofmonth == 2) or (month == 7 and dayofmonth == 1) or (month == 7 and dayofmonth == 30) or (month == 8 and dayofmonth == 28) or (month == 9 and dayofmonth == 25) or (month == 10 and dayofmonth == 26) or (month == 11 and dayofmonth == 25) or (month == 12 and dayofmonth == 24)) ? 1 : nanewMoon2015 = year == 2015 and ((month == 1 and dayofmonth == 16) or (month == 2 and dayofmonth == 18) or (month == 3 and dayofmonth == 19) or (month == 4 and dayofmonth == 17) or (month == 5 and dayofmonth == 15) or (month == 6 and dayofmonth == 16) or (month == 7 and dayofmonth == 15) or (month == 8 and dayofmonth == 14) or (month == 9 and dayofmonth == 11) or (month == 10 and dayofmonth == 12) or (month == 11 and dayofmonth == 11) or (month == 12 and dayofmonth == 10)) ? 1 : nafullMoon2016 = year == 2016 and ((month == 1 and dayofmonth == 22) or (month == 2 and dayofmonth == 22) or (month == 3 and dayofmonth == 22) or (month == 4 and dayofmonth == 21) or (month == 5 and dayofmonth == 20) or (month == 6 and dayofmonth == 17) or (month == 7 and dayofmonth == 19) or (month == 8 and dayofmonth == 17) or (month == 9 and dayofmonth == 16) or (month == 10 and dayofmonth == 14) or (month == 11 and dayofmonth == 11) or (month == 12 and dayofmonth == 13)) ? 1 : nanewMoon2016 = year == 2016 and ((month == 1 and dayofmonth == 8) or (month == 2 and dayofmonth == 8) or (month == 3 and dayofmonth == 8) or (month == 4 and dayofmonth == 6) or (month == 5 and dayofmonth == 6) or (month == 6 and dayofmonth == 3) or (month == 7 and dayofmonth == 1) or (month == 8 and dayofmonth == 2) or (month == 8 and dayofmonth == 31) or (month == 9 and dayofmonth == 30) or (month == 10 and dayofmonth == 28) or (month == 11 and dayofmonth == 28) or (month == 12 and dayofmonth == 28)) ? 1 : nafullMoon2017 = year == 2017 and ((month == 1 and dayofmonth == 11) or (month == 2 and dayofmonth == 10) or (month == 3 and dayofmonth == 10) or (month == 4 and dayofmonth == 10) or (month == 5 and dayofmonth == 10) or (month == 6 and dayofmonth == 8) or (month == 7 and dayofmonth == 7) or (month == 8 and dayofmonth == 7) or (month == 9 and dayofmonth == 5) or (month == 10 and dayofmonth == 5) or (month == 11 and dayofmonth == 3) or (month == 12 and dayofmonth == 1) or (month == 12 and dayofmonth == 29)) ? 1 : nanewMoon2017 = year == 2017 and ((month == 1 and dayofmonth == 27) or (month == 2 and dayofmonth == 24) or (month == 3 and dayofmonth == 27) or (month == 4 and dayofmonth == 25) or (month == 5 and dayofmonth == 25) or (month == 6 and dayofmonth == 23) or (month == 7 and dayofmonth == 21) or (month == 8 and dayofmonth == 21) or (month == 9 and dayofmonth == 19) or (month == 10 and dayofmonth == 19) or (month == 11 and dayofmonth == 17) or (month == 12 and dayofmonth == 15)) ? 1 : nafullMoon2018 = year == 2018 and ((month == 1 and dayofmonth == 30) or (month == 3 and dayofmonth == 1) or (month == 3 and dayofmonth == 29) or (month == 4 and dayofmonth == 27) or (month == 5 and dayofmonth == 29) or (month == 6 and dayofmonth == 27) or (month == 7 and dayofmonth == 27) or (month == 8 and dayofmonth == 24) or (month == 9 and dayofmonth == 24) or (month == 10 and dayofmonth == 24) or (month == 11 and dayofmonth == 21) or (month == 12 and dayofmonth == 21)) ? 1 : nanewMoon2018 = year == 2018 and ((month == 1 and dayofmonth == 16) or (month == 2 and dayofmonth == 15) or (month == 3 and dayofmonth == 16) or (month == 4 and dayofmonth == 13) or (month == 5 and dayofmonth == 14) or (month == 6 and dayofmonth == 13) or (month == 7 and dayofmonth == 12) or (month == 8 and dayofmonth == 10) or (month == 9 and dayofmonth == 7) or (month == 10 and dayofmonth == 8) or (month == 11 and dayofmonth == 7) or (month == 12 and dayofmonth == 6)) ? 1 : nafullMoon2019 = year == 2019 and ((month == 1 and dayofmonth == 18) or (month == 2 and dayofmonth == 19) or (month == 3 and dayofmonth == 20) or (month == 4 and dayofmonth == 18) or (month == 5 and dayofmonth == 17) or (month == 6 and dayofmonth == 14) or (month == 7 and dayofmonth == 16) or (month == 8 and dayofmonth == 14) or (month == 9 and dayofmonth == 13) or (month == 10 and dayofmonth == 11) or (month == 11 and dayofmonth == 11) or (month == 12 and dayofmonth == 11)) ? 1 : nanewMoon2019 = year == 2019 and ((month == 1 and dayofmonth == 4) or (month == 2 and dayofmonth == 4) or (month == 3 and dayofmonth == 6) or (month == 4 and dayofmonth == 4) or (month == 5 and dayofmonth == 3) or (month == 5 and dayofmonth == 31) or (month == 7 and dayofmonth == 2) or (month == 7 and dayofmonth == 31) or (month == 8 and dayofmonth == 29) or (month == 9 and dayofmonth == 27) or (month == 10 and dayofmonth == 25) or (month == 11 and dayofmonth == 26) or (month == 12 and dayofmonth == 24)) ? 1 : nafullMoon2020 = year == 2020 and ((month == 1 and dayofmonth == 10) or (month == 2 and dayofmonth == 7) or (month == 3 and dayofmonth == 9) or (month == 4 and dayofmonth == 7) or (month == 5 and dayofmonth == 6) or (month == 6 and dayofmonth == 5) or (month == 7 and dayofmonth == 2) or (month == 8 and dayofmonth == 3) or (month == 9 and dayofmonth == 1) or (month == 10 and dayofmonth == 1) or (month == 10 and dayofmonth == 30) or (month == 11 and dayofmonth == 27) or (month == 12 and dayofmonth == 29)) ? 1 : nanewMoon2020 = year == 2020 and ((month == 1 and dayofmonth == 24) or (month == 2 and dayofmonth == 21) or (month == 3 and dayofmonth == 23) or (month == 4 and dayofmonth == 22) or (month == 5 and dayofmonth == 22) or (month == 6 and dayofmonth == 19) or (month == 7 and dayofmonth == 20) or (month == 8 and dayofmonth == 18) or (month == 9 and dayofmonth == 16) or (month == 10 and dayofmonth == 16) or (month == 11 and dayofmonth == 13) or (month == 12 and dayofmonth == 14)) ? 1 : nafullMoon2021 = year == 2021 and ((month == 1 and dayofmonth == 28) or (month == 2 and dayofmonth == 26) or (month == 3 and dayofmonth == 26) or (month == 4 and dayofmonth == 26) or (month == 5 and dayofmonth == 25) or (month == 6 and dayofmonth == 24) or (month == 7 and dayofmonth == 23) or (month == 8 and dayofmonth == 20) or (month == 9 and dayofmonth == 20) or (month == 10 and dayofmonth == 20) or (month == 11 and dayofmonth == 18) or (month == 12 and dayofmonth == 17)) ? 1 : nanewMoon2021 = year == 2021 and ((month == 1 and dayofmonth == 12) or (month == 2 and dayofmonth == 11) or (month == 3 and dayofmonth == 12) or (month == 4 and dayofmonth == 9) or (month == 5 and dayofmonth == 11) or (month == 6 and dayofmonth == 9) or (month == 7 and dayofmonth == 9) or (month == 8 and dayofmonth == 6) or (month == 9 and dayofmonth == 6) or (month == 10 and dayofmonth == 5) or (month == 11 and dayofmonth == 4) or (month == 12 and dayofmonth == 3)) ? 1 : na//All Full and New MoonsfullMoon = fullMoon2015 or fullMoon2016 or fullMoon2017 or fullMoon2018 or fullMoon2019 or fullMoon2020 or fullMoon2021newMoon = newMoon2015 or newMoon2016 or newMoon2017 or newMoon2018 or newMoon2019 or newMoon2020 or newMoon2021//Plot Full and New Moons (offset 1 bar to make up for 1 day prior calculation)plotshape(fullMoon, "Full Moon", shape.circle, location.belowbar, color.new(color.gray, 20), offset=1, size=size.normal) plotshape(newMoon, "New Moon", shape.circle, location.abovebar, color.new(color.white, 20), offset=1, size=size.normal)//Define Entry and Exit SignalsentrySignal = (strategy.position_size <= 0 and fullMoon)exitSignal = (strategy.position_size >= 0 and newMoon)//Entry Orderstrategy.order("Full Moon Entry", long = true, when = (strategy.position_size <= 0 and entrySignal))//Exit Orderstrategy.close_all(when = exitSignal, comment = "New Moon Exit")//Background fillbackgroundColour = (strategy.position_size > 0) ? color.green : color.redbgcolor(color=backgroundColour, transp=85)