Pine Script v4 · Strategy
Moon Phases Strategy 2015 till 2021
A Pine Script v4 strategy with no technical-analysis calculation. It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade commits 100% of equity and pays no commission. 13 settings; defaults include From Month 1, From Day 1 and From Year 2015.
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 Moon Phases Strategy 2015 till 2021 repaint?
- Yes
- At least one pattern in the source can repaint: intrabar recalculation.
- How did Moon Phases Strategy 2015 till 2021 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 code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
- Can Moon Phases Strategy 2015 till 2021 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 Moon Phases Strategy 2015 till 2021 use a stop loss?
- Yes
- strategy.exit sets a stop on line 69, 72.
- Does Moon Phases Strategy 2015 till 2021 run in Zeal Terminal?
- Yes
- It compiles in 42 ms and runs 1,000 bars in 473 ms, in the browser.
BTCUSDT · 1D · default settings
- Winning trade
- Losing trade
- Equity
- Buy and hold
- 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
1 setting does nothing
“Show Date Range” is declared but never read.
-
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 60, 61, 63, 64. The upgraded version below moves each call inside an if block.
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.
- 4 strategy calls use the when = argument (line 60, 61, 63, 64). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 2: //@version=4 → //@version=5
- Line 40: input(type = input.integer) → input.int()
- Line 41: input(type = input.integer) → input.int()
- Line 42: input(type = input.integer) → input.int()
- Line 43: input(type = input.integer) → input.int()
- Line 44: input(type = input.integer) → input.int()
- Line 45: input(type = input.integer) → input.int()
- Line 47: input(type = input.bool) → input.bool()
//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: Joy Bangla⋯// === INPUT BACKTEST RANGE ===-fromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12)+fromMonth = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)-fromDay = input(defval = 1, title = "From Day", type = input.integer, minval = 1, maxval = 31)+fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)-fromYear = input(defval = 2015, title = "From Year", type = input.integer, minval = 2015, maxval = 2030)+fromYear = input.int(defval = 2015, title = "From Year", minval = 2015, maxval = 2030)-thruMonth = input(defval = 12, title = "Thru Month", type = input.integer, minval = 1, maxval = 11)+thruMonth = input.int(defval = 12, title = "Thru Month", minval = 1, maxval = 11)-thruDay = input(defval = 30, title = "Thru Day", type = input.integer, minval = 1, maxval = 30)+thruDay = input.int(defval = 30, title = "Thru Day", minval = 1, maxval = 30)-thruYear = input(defval = 2022, title = "Thru Year", type = input.integer, minval = 1900, maxval = 2030)+thruYear = input.int(defval = 2022, title = "Thru Year", minval = 1900, maxval = 2030)// === INPUT SHOW PLOT ===-showDate = input(defval = true, title = "Show Date Range", type = input.bool)+showDate = input.bool(defval = true, title = "Show Date Range")// === FUNCTION EXAMPLE ===⋯Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 52: input() → input.int()
- Line 53: input() → input.int()
- Line 57: input() → input.bool()
- Line 58: input() → input.bool()
- Line 60: when = fullMoon → if block
- Line 61: when = newMoon → if block
4 more edits
- Line 63: when = newMoon → if block
- Line 64: when = fullMoon → if block
- Line 65: input() → input.bool()
- Line 66: input() → input.bool()
⋯window() => time >= start and time <= finish ? true : false // create function "within window of time"-longLossPerc = input(title="Long Stop Loss (%)", minval=0.0, step=0.1, defval=9) * 0.01+longLossPerc = input.int(title="Long Stop Loss (%)", minval=0.0, step=0.1, defval=9) * 0.01-shortLossPerc = input(title="Short Stop Loss (%)", minval=0.0, step=0.1, defval=9) * 0.01+shortLossPerc = input.int(title="Short Stop Loss (%)", minval=0.0, step=0.1, defval=9) * 0.01// Determine stop loss price⋯shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)-testLongOnly = input (true, "Test Long Only")+testLongOnly = input.bool (true, "Test Long Only")-testShortOnly = input (true, "Test Short ONly")+testShortOnly = input.bool (true, "Test Short ONly")if (window() and testLongOnly)- strategy.entry("buy", strategy.long, when=fullMoon)+ if fullMoon+ strategy.entry("buy", strategy.long)- strategy.close_all(when=newMoon)+ if newMoon+ strategy.close_all()if (window() and testShortOnly)- strategy.entry("sell", strategy.short, when=newMoon)+ if newMoon+ strategy.entry("sell", strategy.short)- strategy.close_all(when=fullMoon)+ if fullMoon+ strategy.close_all()-useLongSL = input (false, "Use Long SL")+useLongSL = input.bool (false, "Use Long SL")-useShorSL = input (false, "Use Short SL")+useShorSL = input.bool (false, "Use Short SL")// Submit exit orders based on calculated stop loss price⋯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: Joy Bangla⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| From Month | 1 | int (written input.integer) · min 1 · max 12 | start |
| From Day | 1 | int (written input.integer) · min 1 · max 31 | start |
| From Year | 2015 | int (written input.integer) · min 2015 · max 2030 | start |
| Thru Month | 12 | int (written input.integer) · min 1 · max 11 | finish |
| Thru Day | 30 | int (written input.integer) · min 1 · max 30 | finish |
| Thru Year | 2022 | int (written input.integer) · min 1900 · max 2030 | finish |
| Show Date Range | true | bool | unused |
| Long Stop Loss (%) | 9 | int · min 0.0 · step 0.1 | longStopPrice |
| Short Stop Loss (%) | 9 | int · min 0.0 · step 0.1 | shortStopPrice |
| Test Long Only | true | bool | entry buy close_all line 59 |
| Test Short ONly | true | bool | entry sell close_all line 62 |
| Use Long SL | false | bool | exit XL STP line 68 |
| Use Short SL | false | bool | exit XS STP line 71 |
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open buy long | fullMoonfullMoon2015 or fullMoon2016 or fullMoon2017 or fullMoon2018 or fullMoon2019 or fullMoon2020 or fullMoon2021 | On | 60 |
| Close | newMoonnewMoon2015 or newMoon2016 or newMoon2017 or newMoon2018 or newMoon2019 or newMoon2020 or newMoon2021 | On | 61 |
| Open sell short | newMoonnewMoon2015 or newMoon2016 or newMoon2017 or newMoon2018 or newMoon2019 or newMoon2020 or newMoon2021 | On | 63 |
| Close | fullMoonfullMoon2015 or fullMoon2016 or fullMoon2017 or fullMoon2018 or fullMoon2019 or fullMoon2020 or fullMoon2021 | On | 64 |
| Exit XL STP stop | (strategy.position_size > 0 and useLongSL) | On | 69 |
| Exit XS STP stop | (strategy.position_size < 0 and useShorSL) | On | 72 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 42 ms | Yes 1,000 bars in 473 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
“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: Joy Bangla// Full credit goes to Author: Dustin Drummond https://www.tradingview.com/u/Dustin_D_RLT/// He has allowed me to use his Moon Phase strategy code and modify it.// Thank you Dustin Drummond for allowing me. I really wanted to test out accuracy of moon phase. And I could not done it // without your code//Simple Moon Phases Strategy//It was created to test the Moon Phase theory compared to just a buy and hold strategy.// It buy on full Moon and sell on new Moon. // I also have added 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.strategy(title="Moon Phases Strategy 2015 till 2021", shorttitle = "Moon Phases Strategy", 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.lime, 10), offset=1, size=size.normal) plotshape(newMoon, "New Moon", shape.circle, location.abovebar, color.new(color.red, 10), offset=1, size=size.normal)// STRATEGY// === INPUT BACKTEST RANGE ===fromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12)fromDay = input(defval = 1, title = "From Day", type = input.integer, minval = 1, maxval = 31)fromYear = input(defval = 2015, title = "From Year", type = input.integer, minval = 2015, maxval = 2030)thruMonth = input(defval = 12, title = "Thru Month", type = input.integer, minval = 1, maxval = 11)thruDay = input(defval = 30, title = "Thru Day", type = input.integer, minval = 1, maxval = 30)thruYear = input(defval = 2022, title = "Thru Year", type = input.integer, minval = 1900, maxval = 2030)// === INPUT SHOW PLOT ===showDate = input(defval = true, title = "Show Date Range", type = input.bool)// === FUNCTION EXAMPLE ===start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start windowfinish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish windowwindow() => time >= start and time <= finish ? true : false // create function "within window of time"longLossPerc = input(title="Long Stop Loss (%)", minval=0.0, step=0.1, defval=9) * 0.01shortLossPerc = input(title="Short Stop Loss (%)", minval=0.0, step=0.1, defval=9) * 0.01// Determine stop loss pricelongStopPrice = strategy.position_avg_price * (1 - longLossPerc)shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)testLongOnly = input (true, "Test Long Only")testShortOnly = input (true, "Test Short ONly")if (window() and testLongOnly) strategy.entry("buy", strategy.long, when=fullMoon) strategy.close_all(when=newMoon)if (window() and testShortOnly) strategy.entry("sell", strategy.short, when=newMoon) strategy.close_all(when=fullMoon)useLongSL = input (false, "Use Long SL")useShorSL = input (false, "Use Short SL")// Submit exit orders based on calculated stop loss priceif (strategy.position_size > 0 and useLongSL) strategy.exit(id="XL STP", stop=longStopPrice)// Submit exit orders based on calculated stop loss priceif (strategy.position_size < 0 and useShorSL) strategy.exit(id="XS STP", stop=shortStopPrice)