
이것은 복잡한 다중 지표 거래 전략으로, 거래량 중화 평균 가격 (AVWAP), 고정 범위 거래량 분산 (FRVP), 지수 이동 평균 (EMA), 상대 강도 지수 (RSI), 평균 방향 지수 (ADX) 및 이동 평균 종식 분산 (MACD) 과 같은 여러 기술 분석 도구를 결합하여 지표 집합을 통해 높은 확률의 거래 기회를 식별하기 위해 고안되었습니다.
이 전략은 여러 가지 조건으로 진입 신호를 결정합니다.
전략은 아시아, 런던, 뉴욕 거래 시간대에 초점을 맞추고 있으며, 이러한 시간대는 일반적으로 유동성이 좋으며 거래 신호가 더 신뢰할 수 있습니다. 입시 논리는 긴 포지션과 빈 포지션 두 가지 모드를 포함하며,梯度止 및 중단 메커니즘을 설정합니다.
이것은 고도로 사용자 정의되고 다차원적인 거래 전략으로, 여러 기술적 지표와 거래 시간 특성을 통합하여 거래 신호의 품질과 정확성을 높이기 위해 시도합니다. 이 전략은 수량 거래에서 지표 집약과 동적 위험 관리의 복잡성을 보여줍니다.
/*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)