
これは,取引量重み平均価格 (AVWAP),固定範囲取引量分布 (FRVP),指数移動平均 (EMA),相対力指数 (RSI),平均方向指数 (ADX),移動平均収束散度 (MACD) などの複数の技術分析ツールを組み合わせた複雑な多指標取引戦略であり,指標の集約によって高確率の取引機会を特定することを目的としています.
戦略は,複数の条件によって入場信号を決定します.
戦略は,アジア,ロンドン,ニューヨークの取引時間に焦点を当てており,これらの時間は通常流動性が高く,取引シグナルがより信頼性があります. 入場論理は,長ポジションと空ポジションの2つのモードを含み,梯度ストップとストップ損失の仕組みを設定しています.
これは高度にカスタマイズされ,多次元的な取引戦略であり,複数の技術指標と取引時間特性を統合することによって,取引信号の質と正確性を向上させようとしています.この戦略は,指標集約とダイナミックなリスク管理の複雑さを量化取引で示しています.
/*backtest
start: 2024-04-02 00:00:00
end: 2024-12-31 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"DOGE_USDT"}]
*/
//@version=6
strategy("FRVP + AVWAP by Grok", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// User Inputs
frvpLength = input.int(20, title="FRVP Length", minval=1)
emaLength = input.int(75, title="EMA Length", minval=1) // Adjusted for stronger trend confirmation
rsiLength = input.int(14, title="RSI Length", minval=1)
adxThreshold = input.int(20, title="ADX Strength Threshold", minval=0, maxval=100)
volumeMultiplier = input.float(1.0, title="Volume Multiplier", minval=0.1)
// Stop Loss & Take Profit for XAUUSD
stopLossPips = 25 // 25 pips SL for Asian, London, NY Sessions
takeProfit1Pips = 35 // TP1 at 35 pips
takeProfit2Pips = 80 // Final TP at 80 pips
// Stop-Loss & Take-Profit Multipliers (XAUUSD: 1 pip = 0.1 points on most platforms)
stopMultiplier = float(stopLossPips) * 0.1
tp1Multiplier = float(takeProfit1Pips) * 0.1
tp2Multiplier = float(takeProfit2Pips) * 0.1
// Indicators
avwap = ta.vwap(close) // Volume Weighted Average Price (VWAP)
ema = ta.ema(close, emaLength) // Exponential Moving Average
rsi = ta.rsi(close, rsiLength) // Relative Strength Index
macdLine = ta.ema(close, 12) - ta.ema(close, 26) // MACD Line
signalLine = ta.ema(macdLine, 9) // MACD Signal Line
atr = ta.atr(14) // Average True Range
// Average Directional Index (ADX)
adxSmoothing = 14
[diplus, diminus, adx] = ta.dmi(14, adxSmoothing) // Corrected syntax for ta.dmi()
// Volume Profile (FRVP - Fixed Range Volume Profile Midpoint)
highestHigh = ta.highest(high, frvpLength)
lowestLow = ta.lowest(low, frvpLength)
frvpMid = (highestHigh + lowestLow) / 2 // Midpoint of the range
// Detect Trading Sessions
currentHour = hour(time, "UTC") // Renamed to avoid shadowing built-in 'hour'
isAsianSession = currentHour >= 0 and currentHour < 8
isLondonSession = currentHour >= 8 and currentHour < 16
isNYSession = currentHour >= 16 and currentHour < 23
// Entry Conditions
longCondition = ta.crossover(close, avwap) and close > ema and rsi > 30 and macdLine > signalLine and adx > adxThreshold
shortCondition = ta.crossunder(close, avwap) and close < ema and rsi < 70 and macdLine < signalLine and adx > adxThreshold
// Volume Filter
avgVolume = ta.sma(volume, 20) // 20-period Simple Moving Average of volume
volumeFilter = volume > avgVolume * volumeMultiplier // Trade only when volume exceeds its moving average
// Trade Execution with SL/TP for Sessions
if (longCondition and volumeFilter and (isAsianSession or isLondonSession or isNYSession))
strategy.entry("LongEntry", strategy.long, qty=100)
strategy.exit("LongTP1", from_entry="LongEntry", limit=close + tp1Multiplier)
strategy.exit("LongExit", from_entry="LongEntry", stop=close - stopMultiplier, limit=close + tp2Multiplier)
if (shortCondition and volumeFilter and (isAsianSession or isLondonSession or isNYSession))
strategy.entry("ShortEntry", strategy.short, qty=100)
strategy.exit("ShortTP1", from_entry="ShortEntry", limit=close - tp1Multiplier)
strategy.exit("ShortExit", from_entry="ShortEntry", stop=close + stopMultiplier, limit=close - tp2Multiplier)
// Plotting for Debugging and Visualization
plot(avwap, "AVWAP", color=color.purple, style=plot.style_line, offset=0)
plot(ema, "EMA", color=color.orange, style=plot.style_line, offset=0)
// plot(rsi, "RSI", color=color.yellow, style=plot.style_histogram, offset=0) // Better in a separate pane
// plot(macdLine, "MACD Line", color=color.blue, style=plot.style_histogram, offset=0) // Better in a separate pane
// plot(signalLine, "Signal Line", color=color.red, style=plot.style_histogram, offset=0) // Better in a separate pane
plot(adx, "ADX", color=color.green, style=plot.style_line, offset=0)
// Optional: Plot entry/exit signals for visualization
plotshape(longCondition and volumeFilter ? close : na, title="Long Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.tiny)
plotshape(shortCondition and volumeFilter ? close : na, title="Short Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.tiny)