
Die Strategie berechnet die ATR-Volatilität der Preise, kombiniert mit dem VWAP-Mittelpreis für verschiedene Perioden, setzt die Ein- und Ausstiegsbedingungen für Long-Positions und ermöglicht den Trend-Tracking-Handel mit Aktien.
Die Strategie wird hauptsächlich für die Trendverfolgung von Aktienprodukten verwendet, um Kauf- und Verkaufskonditionen zu bestimmen, um Trends zu beurteilen und zu verfolgen. Die Strategie ist flexibel und kann zwischen Lang- und Kurzlinie umgeschaltet werden.
Die Strategie verwendet die ATR-Indikatoren zur Berechnung der Preisfluktuation und beurteilt die Richtung der Tendenz in Verbindung mit der Frage, ob die Preise den Fluktuationskanal durchbrechen. Die VWAP-Preise für verschiedene Perioden werden zur Beurteilung der Konsistenz der langen und kurzen Trends verwendet. Die spezifische Logik ist wie folgt:
Das ist die zentrale Logik der Strategie. Die ATR-Volatilität beurteilt die kurzfristige Tendenz, die VWAP-Preise beurteilen die langfristige Tendenz, die in Kombination mit der Beurteilung der Trendkonformität ein Handelssignal erzeugen.
Die Strategie ermöglicht die Beobachtung von Aktientrends durch eine doppelte Beurteilung der ATR-Volatilität und des VWAP. Die Strategie hat viel Optimierungsraum und kann Parameter anpassen oder Optimierungssignale für andere technische Indikatoren hinzufügen. Insgesamt ist die Strategie logisch klar und verständlich und eignet sich für die Beobachtung von langen Trends.
/*backtest
start: 2023-12-17 00:00:00
end: 2024-01-16 00:00:00
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/
// © exlux99
//@version=4
strategy(title="VWAP MTF STOCK STRATEGY", overlay=true )
// high^2 / 2 - low^2 -2
h=pow(high,2) / 2
l=pow(low,2) / 2
o=pow(open,2) /2
c=pow(close,2) /2
x=(h+l+o+c) / 4
y= sqrt(x)
source = y
useTrueRange = false
length = input(27, minval=1)
mult = input(0, step=0.1)
ma = sma(source, length)
range = useTrueRange ? tr : high - low
rangema = sma(range, length)
upper = ma + rangema * mult
lower = ma - rangema * mult
crossUpper = crossover(source, upper)
crossLower = crossunder(source, lower)
bprice = 0.0
bprice := crossUpper ? high+syminfo.mintick : nz(bprice[1])
sprice = 0.0
sprice := crossLower ? low -syminfo.mintick : nz(sprice[1])
crossBcond = false
crossBcond := crossUpper ? true
: na(crossBcond[1]) ? false : crossBcond[1]
crossScond = false
crossScond := crossLower ? true
: na(crossScond[1]) ? false : crossScond[1]
cancelBcond = crossBcond and (source < ma or high >= bprice )
cancelScond = crossScond and (source > ma or low <= sprice )
longOnly = true
fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
fromYear = input(defval = 2000, title = "From Year", minval = 1970)
//monday and session
// To Date Inputs
toDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31)
toMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12)
toYear = input(defval = 2021, title = "To Year", minval = 1970)
startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)
finishDate = timestamp(toYear, toMonth, toDay, 00, 00)
time_cond = true
srcX = input(ohlc4)
t = time("W")
start = na(t[1]) or t > t[1]
sumSrc = srcX * volume
sumVol = volume
sumSrc := start ? sumSrc : sumSrc + sumSrc[1]
sumVol := start ? sumVol : sumVol + sumVol[1]
vwapW= sumSrc / sumVol
//crossUpper = crossover(source, upper)
//crossLower = crossunder(source, lower)
shortCondition = close < vwap and time_cond and (close < vwapW)
longCondition = close > vwap and time_cond and (close > vwapW)
if(longOnly and time_cond)
if (crossLower and close < vwapW )
strategy.close("long")
if (crossUpper and close>vwapW)
strategy.entry("long", strategy.long, stop=bprice)