
この戦略は,EMA,VWAP,取引量に基づいた取引戦略である.主な考え方は,特定の取引時間の中で,閉盘価格がVWAPとEMAを突破し,取引量が前K線の取引量より大きいときに開場シグナルを生成することである.同時に,停止損失と止まりを設定し,特定の時間内にポジションを平らにする条件がある.
この戦略は,価格の傾向,市場公正価値および取引量を総合的に考慮して,特定の取引時間内に取引する. ストップ・ローズ・ストップと限られた取引時間を設定したものの,実際の適用では,揺動市場や滑り場などのリスクに注意する必要があります. 将来,より多くのフィルタリング条件,最適化パラメータおよびポジション管理などの方法で戦略の安定性と収益性を向上させることができます.
/*backtest
start: 2024-04-27 00:00:00
end: 2024-04-28 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA, VWAP, Volume Strategy", overlay=true, process_orders_on_close=true)
// Inputs
emaLength = input.int(21, title="EMA Length")
vwapSource = input.source(defval=hlc3, title='VWAP Source')
stopLossPoints = input.float(100, title="Stop Loss (points)")
targetPoints = input.float(200, title="Target (points)")
session = input("0950-1430", title='Only take entry during')
exit = input(defval='1515-1525', title='Exit Trade')
tradein = not na(time(timeframe.period, session))
exit_time = not na(time(timeframe.period, exit))
// Calculate indicators
ema = ta.ema(close, emaLength)
vwapValue = ta.vwap(vwapSource)
// Entry Conditions
longCondition = close > vwapValue and close > ema and volume > volume[1] and close > open and tradein
shortCondition = close < vwapValue and close < ema and volume > volume[1] and open > close and tradein
// Exit Conditions
longExitCondition = ta.crossunder(close, vwapValue) or ta.crossunder(close, ema) or close - strategy.position_avg_price >= targetPoints or close - strategy.position_avg_price <= -stopLossPoints or exit_time
shortExitCondition = ta.crossover(close, vwapValue) or ta.crossover(close, ema) or strategy.position_avg_price - close >= targetPoints or strategy.position_avg_price - close <= -stopLossPoints or exit_time
// Plotting
plot(vwapValue, color=color.blue, title="VWAP")
plot(ema, color=color.green, title="EMA")
// Strategy
if longCondition
strategy.entry("Long", strategy.long)
if shortCondition
strategy.entry("Short", strategy.short)
if longExitCondition
strategy.close('Long', immediately=true)
if shortExitCondition
strategy.close("Short", immediately=true)