TradingView
Dustin_D_RLT
5 de Jul de 2021 22:30

Simple Moon Phases Strategy 

SPDR S&P 500 ETF TRUSTArca

Descrição

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.

WARNING: 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.
Comentários
naufalape
can you update the scrip for 2022 periode ?
Joy_Bangla
Hi

I took your code and updated to ensure

>> open long on the full moon and close long on new moon
>> open short on the new moon && close on full moon

continue that from 2015 till today

The accuracy rate is around 50%

tradingview.com/script/nxFDZMC6-Moon-Phases-Strategy-2015-till-2021/
foldgish85
Thank you for this! Is it correct I can only set a fixed alert, so no separate alert for new and/or full moon?
Dustin_D_RLT
@stokking,

Strategy Alerts don't work the same as Study alerts, unfortunately. Something I would like to see Trading View fix.

You can try changing lines 39 through 41 to this and that "might" give you the alerts you are looking for:

strategy.order("Full Moon Entry", long = true, when = (strategy.position_size <= 0 and entrySignal), alert_message="Full Moon Entry")
//Exit Order
strategy.close_all(when = exitSignal, comment = "New Moon Exit", alert_message="New Moon Exit")
Mais