
Diese Strategie basiert auf den Veränderungen der Mondphasen, wobei man bei Neumond mehr macht und bei Vollmond weniger, um einen beidseitigen Handel zu ermöglichen.
Die Strategie verwendet eine benutzerdefinierte Funktion, um die Monatsphase zu berechnen und das Alter der Monatsphase anhand des Datums zu berechnen. Jüngere als 15 Jahre sind Neumond, ältere als 15 Jahre und jüngere als 30 Jahre sind Vollmond. Die Strategie richtet sich nach der Monatsphase und gibt mehr Leerpositionen an.
Benutzer können wählen, ob sie einen neuen Monat überschreiten, einen vollen Monat überschreiten oder einen neuen Monat überschreiten, einen vollen Monat überschreiten. Die Strategie verwendet die Bull-Variablen, um zu verfolgen, ob der aktuelle Positionsplatz gehalten wird. Wenn keine Positionen vor dem Auftreten des Signals vorhanden sind, werden neue Positionen eröffnet, und wenn das Signal umgedreht wird, werden die aktuellen Positionen ausgeglichen.
Die Risiken können auf folgende Weise gelöst werden:
Diese Strategie kann optimiert werden durch:
Die Strategie nutzt die periodische Gesetzmäßigkeit der Mondphasen, um eine zweiseitige Handelsstrategie zu realisieren, die auf dem Neumond und dem Vollmond basiert. Die Strategie zeigt eine klare, anpassungsfähige Darstellung und ist geeignet, um Longline-Trends zu erfassen.
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ---------------------------© paaax----------------------------
// ---------------- Author1: Pascal Simon (paaax) ----------------
// -------------------- www.pascal-simon.de ---------------------
// ---------------- www.tradingview.com/u/paaax/-----------------
// Source: https://gist.github.com/L-A/3497902#file-moonobject-js
// -------------------------© astropark--------------------------
// --------------- Author2: Astropark (astropark) ---------------
// -------------- https://bit.ly/astroparktrading ---------------
// -------------- www.tradingview.com/u/astropark/---------------
// @version=4
strategy(title="[astropark] Moon Phases [strategy]", overlay=true, pyramiding = 10, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, initial_capital = 100000, currency = currency.USD, commission_value = 0.1)
// INPUT --- {
newMoonColor = input(color.black, "New Moon Color")
fullMoonColor = input(color.white, "Full Moon Color")
fillBackground = input(true, "Fill Background?")
newMoonBackgroundColor = input(#fffff0aa, "New Moon Background Color")
fullMoonBackgroundColor = input(#aaaaaaaa, "Full Moon Background Color")
//} --- INPUT
// FUNCTION --- {
normalize(_v) =>
x = _v
x := x - floor(x)
if x < 0
x := x + 1
x
calcPhase(_year, _month, _day) =>
int y = na
int m = na
float k1 = na
float k2 = na
float k3 = na
float jd = na
float ip = na
y := _year - floor((12 - _month) / 10)
m := _month + 9
if m >= 12
m := m - 12
k1 := floor(365.25 * (y + 4712))
k2 := floor(30.6 * m + 0.5)
k3 := floor(floor((y / 100) + 49) * 0.75) - 38
jd := k1 + k2 + _day + 59
if jd > 2299160
jd := jd - k3
ip := normalize((jd - 2451550.1) / 29.530588853)
age = ip * 29.53
//} --- FUNCTION
// INIT --- {
age = calcPhase(year, month, dayofmonth)
moon =
floor(age)[1] > floor(age) ? 1 :
floor(age)[1] < 15 and floor(age) >= 15 ? -1 : na
//} --- INIT
// PLOT --- {
plotshape(
moon==1,
"Full Moon",
shape.circle,
location.top,
color.new(newMoonColor, 20),
size=size.normal
)
plotshape(
moon==-1,
"New Moon",
shape.circle,
location.bottom,
color.new(fullMoonColor, 20),
size=size.normal
)
var color col = na
if moon == 1 and fillBackground
col := fullMoonBackgroundColor
if moon == -1 and fillBackground
col := newMoonBackgroundColor
bgcolor(col, title="Moon Phase", transp=10)
//} --- PLOT
// STRATEGY --- {
strategy = input("buy on new moon, sell on full moon", options=["buy on new moon, sell on full moon","sell on new moon, buy on full moon"])
longCond = strategy == "buy on new moon, sell on full moon" ? moon == -1 : moon == 1
shortCond = strategy == "buy on new moon, sell on full moon" ? moon == 1 : moon == -1
weAreInLongTrade = false
weAreInShortTrade = false
weAreInLongTrade := (longCond or weAreInLongTrade[1]) and shortCond == false
weAreInShortTrade := (shortCond or weAreInShortTrade[1]) and longCond == false
buySignal = longCond and weAreInLongTrade[1] == false
sellSignal = shortCond and weAreInShortTrade[1] == false
showBuySellSignals = input(defval=true, title = "Show Buy/Sell Signals")
longEnabled = input(true, title="Long enabled")
shortEnabled = input(true, title="Short enabled")
analysisStartYear = input(2017, "Backtesting From Year", minval=1980)
analysisStartMonth = input(1, "And Month", minval=1, maxval=12)
analysisStartDay = input(1, "And Day", minval=1, maxval=31)
analysisStartHour = input(0, "And Hour", minval=0, maxval=23)
analysisStartMinute = input(0, "And Minute", minval=0, maxval=59)
analyzeFromTimestamp = timestamp(analysisStartYear, analysisStartMonth, analysisStartDay, analysisStartHour, analysisStartMinute)
plotshape(showBuySellSignals and buySignal, title="Buy Label", text="Buy", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
plotshape(showBuySellSignals and sellSignal, title="Sell Label", text="Sell", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
strategy.entry("long", strategy.long, when = time > analyzeFromTimestamp and buySignal and longEnabled)
strategy.entry("short", strategy.short, when = time > analyzeFromTimestamp and sellSignal and shortEnabled)
strategy.close("long", when = sellSignal)
strategy.close("short", when = buySignal)
//} --- STRATEGY