이 전략은 Stochastic oscillator 지표에 기반하여 시장의 과매매 상태를 판단하고, 탄력적인 중지 원칙과 결합하여 단기 거래를 수행한다. Stochastic 지표의 금포크 때 더 많이하고, 죽은 포크 때 공백하고, 전기 중심점 기반의 탄력적인 중지를 설정하여 수익을 보장하면서 위험을 제어한다.
스토카스틱 오실레이터 지표에는 %K선과%D선이 포함되어 있다. %K선이 아래에서 위로 %D선을 돌파할 때, 금叉 신호로, 더 많이 한다. %K선이 위에서 아래로 %D선을 돌파할 때, 사다리 신호로, 공백한다. 이 전략은 스토카스틱 지표의 금叉 사다리 신호를 판단하여 출전한다.
구체적으로, 스토카스틱 지표 금포크 때, %K 선값이 80보다 작으면 (너무 사지 않은 경우) 더 많이 한다. 스토카스틱 지표 사다포크 때, %K 선값이 20보다 크면 (너무 사지 않은 경우) 더 많이 한다.
GoLong=crossover(k,d) and k<80
GoShort=crossunder(k,d) and k>20
이 전략은 탄력적인 스톱 방식을 사용하여 이전 축의 중심점에 따라 스톱 가격을 설정합니다. 코드는 다음과 같습니다.
piv_high = pivothigh(high,1,1)
piv_low = pivotlow(low,1,1)
stoploss_long=valuewhen(piv_low,piv_low,0)
stoploss_short=valuewhen(piv_high,piv_high,0)
축 지점은 중요한 지원 저항을 나타냅니다. 가격이 축 지점을 뚫면, 포지션을 탈퇴하고, 정지 가격의 탄력 이 축 지점 변화에 따라 달라집니다.
또한, 정지 가격은 현재 기간의 최저 가격과 최고 가격을 고려하여 정지 위치를 더 최적화합니다.
if GoLong
stoploss_long := low<pl ? low : pl
if GoShort
stoploss_short := high>ph ? high : ph
시장의 과매매 현상을 판단하기 위해 스토카스틱 지표를 사용하며, 시가 상승과 하락을 추적하는 것을 피하십시오.
유연한 중지 원칙을 적용하여 시장 변화에 따라 중지 위치를 최적화 할 수 있습니다.
그 중 하나는 HACCP (Core Axis Breakthrough) 에 의해 HACCP의 효율성을 높이는 것입니다.
현재 최고 최저 가격을 고려하여 스톱 로즈 최적화를 통해 스톱 로즈가 더 정확하도록 한다.
스토카스틱 지표가 잘못된 신호를 보내는 위험
상쇄 손실의 위험성
거래의 빈도가 거래 수수료의 증가로 인한 위험
손해 중지 전략을 최적화합니다. Chandelier Exit, 이동 손해 중지, 진동 손해 중지 등과 같은 방법
입시 조건을 최적화하여 다른 지표와 결합하여 Stochastic 지표의 가짜 신호를 피하십시오.
이동식 차단, 진동식 차단과 같은 절전 방법을 최적화하여 더 높은 절전 수익률을 달성합니다.
위치 관리를 추가하여, 단위 위험을 제어하기 위해, 단위 수를 고정하고, 투자 비율을 고정합니다.
최적화 파라미터를 설정합니다. 예를 들어 K, D, 평형 주기 등과 같은 다른 시장에 맞는 조정 파라미터를 설정합니다.
이 전략은 Stochastic 지표를 통해 오버 바이 오버 소드 상태를 판단하여 입시를 하고, 탄력적인 스톱 손실 방식을 사용하여 리스크 관리를 한다. 이 전략은 상하를 쫓는 것을 피하고, 손실을 효과적으로 막는 등의 장점이 있지만, 특정 잘못된 신호 위험도 존재한다. 향후 입시 조건, 스톱 손실 전략, 스톱 중지 방법, 위험 관리 등의 측면에서 이 전략을 더욱 개선할 수 있다.
/*backtest
start: 2023-08-28 00:00:00
end: 2023-09-27 00:00:00
period: 2h
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/
// © Peter_O
//@version=4
//strategy(title="TradingView Alerts to MT4 MT5 example with cancelling pending orders", commission_type=strategy.commission.cash_per_order, commission_value=0.00003, overlay=true, default_qty_value=100000, initial_capital=1000)
// This script was created for educational purposes only.
// It is showing how to create pending orders and cancel them
// Together with syntax to send these events through TradingView alerts system
// All the way to brokers for execution
TakeProfitLevel=input(400)
// **** Entries logic **** {
periodK = 13 //input(13, title="K", minval=1)
periodD = 3 //input(3, title="D", minval=1)
smoothK = 4 //input(4, title="Smooth", minval=1)
k = sma(stoch(close, high, low, periodK), smoothK)
d = sma(k, periodD)
// plot(k, title="%K", color=color.blue)
// plot(d, title="%D", color=color.orange)
// h0 = hline(80)
// h1 = hline(20)
// fill(h0, h1, color=color.purple, transp=75)
GoLong=crossover(k,d) and k<80
GoShort=crossunder(k,d) and k>20
// } End of entries logic
// **** Pivot-points and stop-loss logic **** {
piv_high = pivothigh(high,1,1)
piv_low = pivotlow(low,1,1)
var float stoploss_long=low
var float stoploss_short=high
pl=valuewhen(piv_low,piv_low,0)
ph=valuewhen(piv_high,piv_high,0)
if GoLong
stoploss_long := low<pl ? low : pl
if GoShort
stoploss_short := high>ph ? high : ph
plot(stoploss_long, color=color.lime, title="stoploss_long")
plot(stoploss_short, color=color.red, title="stoploss_short")
// } End of Pivot-points and stop-loss logic
CancelLong=crossunder(low,stoploss_long) and strategy.position_size[1]<=0 and strategy.position_size<=0
CancelShort=crossover(high,stoploss_short) and strategy.position_size[1]>=0 and strategy.position_size>=0
entry_distance=input(10, title="Entry distance for stop orders")
plotshape(CancelLong ? stoploss_long[1]-10*syminfo.mintick : na, location=location.absolute, style=shape.labelup, color=color.gray, textcolor=color.white, text="cancel\nlong", size=size.tiny)
plotshape(CancelShort ? stoploss_short[1]+10*syminfo.mintick : na, location=location.absolute, style=shape.labeldown, color=color.gray, textcolor=color.white, text="cancel\nshort", size=size.tiny)
strategy.entry("Long", strategy.long, when=GoLong, stop=close+entry_distance*syminfo.mintick)
strategy.exit("XLong", from_entry="Long", stop=stoploss_long, profit=TakeProfitLevel)
strategy.cancel("Long", when = CancelLong)
strategy.entry("Short", strategy.short, when=GoShort, stop=close-entry_distance*syminfo.mintick)
strategy.exit("XShort", from_entry="Short", stop=stoploss_short, profit=TakeProfitLevel)
strategy.cancel("Short", when = CancelShort)
if GoLong
alertsyntax_golong='long offset=' + tostring(entry_distance) + ' slprice=' + tostring(stoploss_long) + ' tp=' + tostring(TakeProfitLevel)
alert(message=alertsyntax_golong, freq=alert.freq_once_per_bar_close)
if GoShort
alertsyntax_goshort='short offset=' + tostring(-entry_distance) + ' slprice=' + tostring(stoploss_short) + ' tp=' + tostring(TakeProfitLevel)
alert(message=alertsyntax_goshort, freq=alert.freq_once_per_bar_close)
if CancelLong
alertsyntax_cancellong='cancel long'
alert(message=alertsyntax_cancellong, freq=alert.freq_once_per_bar_close)
if CancelShort
alertsyntax_cancelshort='cancel short'
alert(message=alertsyntax_cancelshort, freq=alert.freq_once_per_bar_close)