
양방향 압력 강화 거래 전략은 무작위 지표와 거래량 지표를 결합한 트렌드 추적 전략이다. 이 전략은 주로 무작위 지표 K와 D 라인 및 거래량 지표를 사용하여 구매 및 판매 신호를 생성하며, 평행 선 금포 및 사다리 추가 신호를 생성한다.
구매 신호의 주요 트리거는 다음과 같습니다.
K선과 D선 동시에 상하의 초과 지역 (예를 들어 20), 그리고 상향 교차를 생성하고, K선과 D선 동시에 상승 추세에 있습니다
거래량이 특정 임계값보다 높습니다 (예를 들어 평균 거래량의 1.4배)
상장 가격보다 높은 상장 가격 (백색 K선)
추가적인 구매 신호는 다음과 같은 것에서 나올 수 있습니다.
평균선 금포크: 빠른 EMA 선에서 느린 EMA 선을 통과하고 두 개의 평균 선이 동시에 상승
K선과 D선 동시에 낮은 지점에서 초과된 영역으로 들어갑니다 (예를 들어 20 아래에서 20에서 80의 영역으로 올라갑니다)
판매 신호의 주요 트리거는 다음과 같습니다.
K선과 D선 동시에 과매매 구역 (예를 들어 80) 에 들어갑니다.
평균선 사각지대: 빠른 EMA 라인 아래에서 느린 EMA 라인을 통과
K선은 D선을 통과하고 K선과 D선이 동시에 하향 추세에 있습니다.
구매 가격의 일정 비율 (예를 들어 6%) 을 스톱 로즈 라인으로 설정하고, 가격이 이 라인을 넘어간다면 스톱 로즈 판매를 트리거한다.
단일 무작위 지표는 많은 양의 가짜 신호를 생성할 수 있다. 이 전략은 K선과 D선 (K선의 이동 평균선) 이중 무작위 지표 조합을 사용하여, 가짜 신호를 효과적으로 필터링하여 신호의 신뢰성을 보장한다.
거래량 조건은 거래량이 일정 수준을 초과해야 함을 판단하는 보조 기준으로 추가하여 낮은 양의 비 트렌드 구매 및 판매 지점을 필터링하여 포지션의 위험을 줄일 수 있습니다.
전략은 무작위 지표, 거래량 지표, 평균 지표 여러 개의 구매/판매 신호를 통합합니다. 이 신호들은 동시에 촉발되어야 진정한 거래 신호를 생성할 수 있습니다. 여러 가지 지표의 중첩은 신호의 신뢰성을 높일 수 있습니다.
평균선 판단 규칙을 추가하여, 예를 들어, 평균선이 동시에 상승할 때만 구매 신호를 고려하십시오. 이것은 역동적인 구매를 피하거나 을 피하고, 큰 시간 주기에서 트렌드를 판단 할 수 있습니다.
전략에는 스톱로스 신호 설계가 포함되어 있으며, 가격이 구매할 때 일정 비율을 떨어뜨리면 자동으로 스톱로스된다. 이것은 단일 거래의 최대 손실을 효과적으로 제어할 수 있다.
이 전략에는 무작위 지표 변수, 평균 변수, 교량 변수 등 여러 가지 변수가 포함되어 있습니다. 이러한 변수는 다른 품종에 대해 최적화해야하며, 부적절한 설정으로 결과가 좋지 않을 수 있습니다.
스톱포인트를 설정할 때, 가격 폭파의 가능성을 고려할 필요가 있다. 스톱포인트가 구매 가격에 너무 가깝다면, 폭파로 인해 불필요한 스톱포인이 발생할 수 있다.
유동성이 낮은 품종의 경우, 교류량 규칙이 과도한 신호를 필터링 할 수 있습니다. 이 경우 교류량 조건의 제한을 낮추는 것이 필요합니다.
서로 다른 주기 지표들 사이에 위치 순서 불일치 문제가 발생할 수 있으며, 이는 신호의 정확성에 영향을 미칠 수 있다. 신호의 위치 순서 일치성을 검증해야 한다.
이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.
최적화 매개 변수
기계 학습 방법의 동적으로 조정된 변수를 추가합니다.
손실을 줄이기 위한 최적화 전략
더 많은 필터링 조건을 추가하고 거래 수를 줄입니다.
조건부 단일 또는 정지 전략으로 수익률을 높여보세요.
유전 알고리즘과 같은 더 체계적인 방법을 통해 주요 변수를 최적화하여 다른 시장 주기에서 변수가 안정적인 성능을 얻을 수 있도록 보장 할 수 있습니다.
모델은 시장 상태를 실시간으로 평가하고, 그에 따라 전략 파라미터를 조정하여 파라미터를 동적으로 최적화 할 수 있습니다.
더 나은 스톱 로즈 전략을 연구할 수 있습니다. 위험을 통제하면서 불필요한 스톱 로즈를 최대한 줄이고 수익을 올릴 수 있습니다.
적절한 필터링 조건을 강화하여 거래 수를 줄이고 거래 비용의 영향을 줄이고 거래당 수익률을 높일 수 있습니다.
시장의 특성에 따라, 설계 조건 단일 전략 또는 이동 중지 전략, 손실을 막는 동시에 이익을 최대한으로 극대화 할 수 있습니다.
이 전략은 종합적으로 트렌드 판단, 위험 제어, 거래 빈도 등 여러 측면을 고려한다. 핵심 장점은 쌍적 무작위 지표가 교류량 지표 판단 트렌드를 결합하고, 위험 제어의 중지 손해 메커니즘이다. 다음 단계는 매개 변수 안정성을 높이고, 동적으로 매개 변수를 조정하고, 중지 손해 비율을 줄이는 등의 측면에서 최적화 될 수 있어 전략은 더 많은 시장 환경에서 안정적인 수익을 얻을 수 있다.
/*backtest
start: 2023-10-02 00:00:00
end: 2023-11-01 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
// SW SVE - Stochastic+Vol+EMAs [Sergio Waldoke]
// Script created by Sergio Waldoke (BETA VERSION v0.5, fine tuning PENDING)
// Stochastic process is the main source of signals, reinforced on buying by Volume. Also by Golden Cross.
// Selling is determined by K and D entering overselling zone or EMA's Death Cross signal, the first occurring,
// and some other signals combined.
// Buy Long when you see a long buy arrow.
// Sell when you see a close arrow.
// This is a version to be tuned and improved, but already showing excelent results after tune some parameters
// according to the kind of market.
// Strategy ready for doing backtests.
// SVE SYSTEM DESIGN:
// Buy Signal Trigger:
// - Both Stoch <= 20 crossing up and both growing and green candle and Vol/sma vol >= 1.40 Avg Vol
// or
// - Both Stoch growing up and Vol/sma vol >= 1.40 Avg Vol and green candle and
// both prior Stoch crossing up
// or
// [OPTIONAL]: (Bad for BTC 2018, excelent for 2017)
// - Crossingover(fast_ema, slow_ema) and growing(fast_ema) and growing(slow_ema) and green candle
// Exit position:
// - Both Stoch <= 20 and Both Stoch were > 20 during position
// or
// - CrossingUnder(Fast EMA, Medium EMA)
// or [OPTIONAL] (Better for BTC 2018, Worse for BNB 1H)
// - CrossingUnder(k, d) and (k and d starting over over_buying) and (k and d descending) and k crossing down over_buying line
//calc_on_every_tick=true,
//calc_on_order_fills=true, (affects historical calculation, triggers in middle of the bar, may be better for automatic orders)
strategy("SW SVE - Stochastic+Vol+EMAs [Sergio Waldoke]", shorttitle="SW SVE", overlay=true, max_bars_back=5000,
default_qty_type=strategy.percent_of_equity, default_qty_value=100, currency="USD",
commission_type=strategy.commission.percent, commission_value=0.25)
//Strategy Parameters
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 = 2018, title = "From Year", minval = 2009, maxval = 2200)
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 = 2030, title = "To Year", minval = 2009, maxval = 2200)
//Indicator Parameters
//Original defaults for 4HS: 14, 3, 80, 20, 14, 23, 40, 20, 40, 3:
stoch_k = input(title="Stoch K", defval=14, minval=1)
stoch_d = input(title="Stoch D", defval=3, minval=1)
over_buying = input(title="Stoch Overbuying Zone", defval=80, minval=0, maxval=100)
over_selling = input(title="Stoch Overselling Zone", defval=20, minval=0, maxval=100)
fast_ema_periods = input(title="Fast EMA (Death Cross)", defval=14, minval=1, maxval=600)
slow_ema_periods = input(title="Slow EMA (Death Cross)", defval=23, minval=1, maxval=600)
trend_ema_periods = input(title="Slowest EMA (Trend Test)", defval=40, minval=1, maxval=600)
volume_periods = input(title="Volume Periods", defval=20, minval=1, maxval=600)
volume_factor = input(title="Min Volume/Media Increase (%)", defval=80, minval=-100) / 100 + 1
threshold_sl_perc = input(title="[Sell Trigger] Stop Loss Threshold %", defval=6.0, type=float, minval=0, maxval=100)
//before_buy = input(title="# Growing Before Buy", defval=2, minval=1)
//before_sell = input(title="# Decreasing Before Sell", defval=1, minval=1)
//stepsignal = input(title="Show White Steps", type=bool, defval=true)
//steps_base = input(title="White Steps Base", defval=242, minval=0)
//Signals
fast_ema = ema(close, fast_ema_periods)
slow_ema = ema(close, slow_ema_periods)
trend_ema = ema(close, trend_ema_periods)
k = stoch(close, high, low, stoch_k)
d = sma(k, stoch_d)
vol_ma = sma(volume, volume_periods)
//REVIEW CONSTANT 1.75:
in_middle_zone(a) => a > over_selling * 1.75 and a < over_buying
growing(a) => a > a[1]
was_in_middle_zone = k == d
was_in_middle_zone := was_in_middle_zone[1] or in_middle_zone(k) and in_middle_zone(d)
//Buy Signal Trigger:
//- Both Stoch <= 20 crossing up and both growing and
// green candle and Vol/sma vol >= 1.40 Avg Vol
buy = k <= over_selling and d <= over_selling and crossover(k, d) and growing(k) and growing(d) and
close > open and volume/vol_ma >= volume_factor
//or
//- Both Stoch growing up and Vol/sma vol >= 1.40 Avg Vol and green candle and
// both prior Stoch crossing up
buy := buy or (growing(k) and growing(d) and volume/vol_ma >= volume_factor and close > open and
crossover(k[1], d[1]) )
//Worse:
// (crossover(k[1], d[1]) or (crossover(k, d) and k[1] <= over_selling and d[1] <= over_selling) ) )
//or
// [OPTIONAL]: (Bad for BTC 2018, excelent for 2017)
//- Crossingover(fast_ema, slow_ema) and growing(fast_ema) and growing(slow_ema) and green candle
buy := buy or (crossover(fast_ema, slow_ema) and growing(fast_ema) and growing(slow_ema) and close > open)
//Debug:
//d1 = close > open ? 400 : 0
//plot(d1+5200, color=white, linewidth = 3, style = stepline)
//Exit position:
//- Both Stoch <= 20 and Both Stoch were > 20 during position
sell = k <= over_selling and d <= over_selling and was_in_middle_zone
// or
//- CrossingUnder(Fast EMA, Medium EMA)
sell := sell or crossunder(fast_ema, slow_ema)
// or [OPTIONAL] (Better for BTC 2018, Worse for BNB 1H)
//- CrossingUnder(k, d) and (k and d starting over over_buying) and (k and d descending) and k crossing down over_buying line
sell := sell or (crossunder(k, d) and k[1] >= over_buying and d[1] >= over_buying and
not growing(k) and not growing(d) and k <= over_buying)
color = buy ? green : red
bought_price = close
bought_price := nz(bought_price[1])
already_bought = false
already_bought := nz(already_bought[1], false)
//Date Ranges
buy := buy and not already_bought
//d1 = buy ? 400 : 0
//plot(d1+6500, color=white, linewidth = 3, style = stepline)
was_in_middle_zone := (not buy and was_in_middle_zone) or (in_middle_zone(k) and in_middle_zone(d))
already_bought := already_bought[1] or buy
bought_price := buy ? close * (1 - threshold_sl_perc/100) : bought_price[1]
trigger_SL = close < bought_price[0]
sell := sell or trigger_SL
sell := sell and
already_bought and not buy and (was_in_middle_zone or trigger_SL)
//plot((sell?400:0)+5200, title="Buy-Sell", color=yellow, linewidth = 3, style = stepline)
already_bought := already_bought[0] and not sell
bought_price := sell ? 0 : bought_price[0]
//plot((was_in_middle_zone?400:0)+5200, title="Buy-Sell", color=yellow, linewidth = 3, style = stepline)
was_in_middle_zone := not sell and was_in_middle_zone
//Plot signals
plot(fast_ema, title="Fast EMA", color=red, linewidth = 4)
plot(slow_ema, title="Slow EMA", color=blue, linewidth = 4)
plot(trend_ema, title="Trend EMA", color=yellow, linewidth = 4)
//Stop Loss
plot(bought_price, color=gray, linewidth=2, style=cross, join=true, title="Stop Loss")
//Y = stepsignal ? lowest(40) : na
//Y = steps_base
//plot(mysignal+Y, title="Steps", color=white, linewidth = 3, style = stepline)
//Unit steps - for debugging
//plot(mysteps+Y, title="Steps2", color=yellow, linewidth = 3, style = stepline)
//Bought or not - for debugging
//plot((already_bought?400:0)+5200, title="Buy-Sell", color=yellow, linewidth = 3, style = stepline)
//plot((sell?400:0)+5200, title="Buy-Sell", color=yellow, linewidth = 3, style = stepline)
plotshape(buy, title="Buy arrows", style=shape.arrowup, location=location.belowbar, color=color, text="Buy", textcolor=color, size=size.huge, transp=30)
plotshape(sell, title="Sell arrows", style=shape.arrowdown, location=location.abovebar, color=color, text="Sell", textcolor=color, size=size.huge, transp=30)
//if n>2000
strategy.entry("buy", strategy.long, when=buy)
strategy.close_all(when=sell)
//plot(strategy.equity, title="Equity", color=white, linewidth = 4, style = line)
//AlertS trigger
//msg = "[SW Magic Signals EMA] BUY/SELL Signal has been triggered." + "(" + tostring(fastema) + ", " + tostring(slowema) + ") on " + tickerid + ", " + period + "."
msg = "SW SVE BUY/SELL Signal has been triggered. (#, #) on EXCH:PAIR, period: #."
alertcondition(buy or sell, title="SW SVE (BUY/SELL SIGNAL)", message=msg)
alertcondition(buy, title="SW SVE (BUY SIGNAL)", message=msg)
alertcondition(sell, title="SW SVE (SELL SIGNAL)", message=msg)