
이 전략의 핵심 아이디어는 EMA와 WMA의 교차를 입문 신호로 사용하여 점수 계산 기반의 스톱로드를 결합하여 거래를 하는 것이다. 그것의 가장 큰 장점은 매우 유연하고 정확한 위험을 제어할 수 있다는 것이다. 점수 크기를 조정하여 스톱로드 폭을 제어할 수 있다.
EMA가 아래에서 위쪽으로 WMA를 돌파할 때 다중 신호를 생성하고; EMA가 위로부터 아래로 WMA를 돌파할 때, 공백 신호를 생성한다. 입위한 후, 실시간으로 입시 지점을 계산하고, 그 기초에 스톱로즈와 스톱을 설정한다. 예를 들어, 스톱로즈 20을 설정하고, 스톱로즈 100을 설정하면, 구체적인 스톱로즈 가격은 입시 가격에서 20을 빼는 것이다.*계약 가치, 100점 더한 입시 가격*계약 가치. 위험과 수익을 통제하기 위해.
동시에, 전략은 현재의 상장과 역사적인 상장 비교를 결합하여, 이동 상장 위치를 조정하여, 유동 상장 추적 가격을 실현한다.
일반적인 고정 점수 또는 퍼센트 스톱에 비해, 이 전략의 가장 큰 장점은 매우 유연하고 정확한 위험을 제어 할 수 있다는 것입니다. 점수의 크기를 조정하면 스톱의 크기에 직접적으로 영향을 줄 수 있습니다. 이것은 다른 품종에 매우 적합하며, 시장의 변동 빈도와 크기에 따라 미세하게 조정 할 수 있습니다.
또한, 유동적 스톱은 매우 실용적인 기능이기도 합니다. 그것은 실황의 실시간 변화에 따라 스톱 위치를 조정하는 것을 추적할 수 있으며, 위험 통제를 보장하면서 가능한 한 큰 수익을 추구할 수 있습니다.
이 전략의 위험은 주로 EMA와 WMA 두 지표 자체에서 온다. 시장 상황이 급격하게 변하면, 그들은 종종 잘못된 신호를 발산하고, 손해가 발생할 수 있다. 이 경우, 적절한 손해 지점을 완화하거나, 다른 지표 조합을 대체하는 것을 고려하는 것이 좋습니다.
또 다른 위험점은 손해 막이 동시에 유지되기 어렵다는 것입니다. 더 높은 막을 추구하는 경우 일반적으로 더 큰 위험을 감수해야하며, 이는 시장이 변할 때 쉽게 멈출 수 있습니다. 따라서 손해 막의 설정은 신중하게 테스트 및 평가해야합니다.
이 전략은 다음과 같은 방향으로 최적화될 수 있습니다.
이 전략의 핵심 아이디어는 간단하고 명확하며, EMA와 WMA 지표를 기반으로, 점수 계산 기반의 스톱 스 메커니즘을 사용하여 위험을 제어한다. 전략의 장점은 위험 제어가 정확하고 유연하며, 다른 시장에 따라 적절하게 조정할 수 있다는 것이다. 후속적으로 입시 신호, 매개 변수 선택, 스톱 스 메커니즘 등의 측면에서 심도 최적화를 통해 전략이 복잡한 변화하는 시장 환경에 더 잘 적응할 수 있다.
/*backtest
start: 2024-01-03 00:00:00
end: 2024-01-10 00:00:00
period: 45m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// inspiration script from: @ahmad_naquib
// inspiration script link: https://www.tradingview.com/script/tGTV8MkY-Two-Take-Profits-and-Two-Stop-Loss/
// inspiration strategy script name: Two Take Profits and Two Stop Loss
////////////
// Do not use this strategy, it's just an exmaple !! The goal from this script is to show you TP and SL based on PIPS
////////////
//@version=5
strategy('SL & TP based on Pips', "PIP SL & TP", overlay=true, initial_capital=1000)
// MA
ema_period = input(title='EMA period', defval=10)
wma_period = input(title='WMA period', defval=20)
ema = ta.ema(close, ema_period)
wma = ta.wma(close, wma_period)
// Entry Conditions
long = ta.crossover(ema, wma) and nz(strategy.position_size) == 0
short = ta.crossunder(ema, wma) and nz(strategy.position_size) == 0
// Pips Calculation
pip1 = input(20, title = "TP PIP", group = "PIP CALCULATION") * 10 * syminfo.mintick
pip2 = input(20, title = "SL PIP", group = "PIP CALCULATION") * 10 * syminfo.mintick
// Trading parameters
var bool LS = na
var bool SS = na
var float EP = na // Entry Position
var float TVL = na
var float TVS = na
var float TSL = na
var float TSS = na
var float TP1 = na
//var float TP2 = na
var float SL1 = na
///var float SL2 = na
// SL & TP Values
// there's also SL2 and TP2 in case you want to add them to your script,
//also you can add a break event in the strategy.entry section.
if short or long and strategy.position_size == 0
EP := close
SL1 := EP - pip2 * (short ? -1 : 1)
//SL2 := EP - pip2 * (short ? -1 : 1)
TP1 := EP + pip1 * (short ? -1 : 1)
//TP2 := EP + pip1 * 2 * (short ? -1 : 1)
// current trade direction
LS := long or strategy.position_size > 0
SS := short or strategy.position_size < 0
// adjust trade parameters and trailing stop calculations
TVL := math.max(TP1, open) - pip1[1]
TVS := math.min(TP1, open) + pip1[1]
TSL := open[1] > TSL[1] ? math.max(TVL, TSL[1]) : TVL
TSS := open[1] < TSS[1] ? math.min(TVS, TSS[1]) : TVS
//if LS and high > TP1
//if open <= TP1
//SL2 := math.min(EP, TSL)
//if SS and low < TP1
//if open >= TP1
//SL2 := math.max(EP, TSS)
// Closing conditions
// and those are a closing conditions in case you want to add them.
//close_long = LS and open < SL2
//close_short = SS and open > SL2
// Buy
if (long and not SS)
strategy.entry('buy', strategy.long)
strategy.exit('exit1', from_entry='buy', stop=SL1, limit=TP1, qty_percent=100)
//strategy.exit('exit2', from_entry='buy', stop=SL2, limit=TP2)
// Sell
if (short and not LS)
strategy.entry('sell', strategy.short)
strategy.exit('exit3', from_entry='sell', stop=SL1, limit=TP1, qty_percent=100)
//strategy.exit('exit4', from_entry='sell', stop=SL2, limit=TP2)
// Plots
// those are plots for the lines of The tp and sl. they are really useful, and in the next update I will use a filling option.
a = plot(strategy.position_size > 0 ? SL1 : na, color=color.new(#af0829, 30), linewidth = 2, style=plot.style_linebr)
b = plot(strategy.position_size < 0 ? SL1 : na, color=color.new(#af0829, 30), linewidth = 2, style=plot.style_linebr)
c = plot(strategy.position_size > 0 ? TP1 : na, color=color.new(#2e7e00, 30), linewidth = 2, style=plot.style_linebr)
d = plot(strategy.position_size < 0 ? TP1 : na, color=color.new(#2e7e00, 30), linewidth = 2, style=plot.style_linebr)
g = plot(strategy.position_size >= 0 ? na : EP, color=color.new(#ffffff, 50), style=plot.style_linebr)
h = plot(strategy.position_size <= 0 ? na : EP, color=color.new(#ffffff, 50), style=plot.style_linebr)
// those are plot for the TP2 and SL2, they are optional if you want to add them.
//e = plot(strategy.position_size > 0 ? TP2 : na, color=color.new(#00ced1, 0), style=plot.style_linebr)
//f = plot(strategy.position_size < 0 ? TP2 : na, color=color.new(#00ced1, 0), style=plot.style_linebr)
//those are the plot for the ema and wma strategy for short and long signal. they are not really a good strategy, I just used them as an example
//but you have the option to plot them or not.
// do not use this strategy, it's just an exmaple !! The goal from this script is to show you TP and SL based on PIPS
//plot(ema, title='ema', color=color.new(#fff176, 0))
//plot(wma, title='wma', color=color.new(#00ced1, 0))