
최상위 EMA 교차 전략은 가격 교차와 지수 이동 평균 (EMA) 의 교차를 기반으로 한 거래 전략이다. 이 전략은 지정된 주기 내의 최고 가격을 구매 신호로, EMA를 판매 신호로 사용한다. 상장 가격이 지정된 주기 내의 최고 가격을 돌파할 때, 전략은 구매 신호를 발생시킨다. 상장 가격이 EMA를 넘어서는 경우, 전략은 판매 신호를 발생시킨다. 이 전략은 또한 위험을 제어하기 위해 중지 가격을 설정한다.
최고 가격을 돌파하는 EMA 교차 전략의 핵심 원칙은 가격 돌파와 EMA 교차를 사용하여 시장 추세를 포착하는 것입니다. 가격이 지정된 기간의 최고 가격을 돌파하면 시장이 상승 추세에 들어갈 수 있음을 나타냅니다. 따라서 전략은 구매 신호를 발생시킵니다. 동시에, EMA는 추세를 추적하는 지표로서 가격이 EMA를 넘어서는 경우 상승 추세가 끝날 수 있음을 나타냅니다. 따라서 전략은 판매 신호를 발생시킵니다.
이 전략은 다음과 같은 단계를 통해 거래가 이루어집니다.
위와 같은 단계를 통해, 이 전략은 시장의 상승 추세에서 이익을 얻을 수 있으며, 동시에 하향 위험을 제어하기 위해 스톱로스를 사용할 수 있습니다.
가장 높은 EMA를 돌파하는 교차 전략은 다음과 같은 장점이 있습니다.
최상위 EMA를 돌파하는 EMA 교차 전략에는 장점이 있지만 다음과 같은 위험도 있습니다.
이러한 위험을 완화하기 위해 다음과 같은 조치를 고려할 수 있습니다.
최고 가격 EMA 교차 전략의 성능을 더욱 향상시키기 위해 다음과 같은 최적화 방향을 고려할 수 있습니다.
이러한 최적화 조치는 최고 가격 EMA 교차 전략의 안정성, 적응성 및 수익성을 향상시킬 수 있으며, 이를 통해 더 많은 시장 환경에서 좋은 성과를 낼 수 있습니다.
최상위 가격 EMA 교차 전략은 가격 교차와 EMA 교차를 활용하여 시장의 추세를 포착하고 동시에 스톱로스를 사용하여 하향 위험을 제어하는 간단한 효과적 인 트렌드 추적 전략입니다. 이 전략의 논리는 명확하고, 매개 변수는 유연하며, 이해하기 쉽고 구현 할 수 있습니다. 이 전략에는 시장의 변동 위험, 추세 전환 위험 및 매개 변수 설정 위험과 같은 특정 위험이 있지만, 적절한 위험 제어 조치를 통해 이러한 위험을 완화 할 수 있습니다.
/*backtest
start: 2024-02-01 00:00:00
end: 2024-02-29 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// @version = 5
strategy(title="BreakHigh Strategy", overlay=true)
Period = input.int(34, "Number of previous bars(34,52 Recommend)")
showbg = input(defval = false,title = "Show BackGround Color")
showema = input(defval = true ,title = "Show Line")
MarkBuySig = input(defval = true ,title = "Show Buy/Sell Signal")
Risk_Per_Trade = input(2.5, '% of Risk Per Trade') / 100 // Risk% Per Trade Switch
SLDAY = input(title='Lowest price of the previous number of bars', defval=9)
Buysig = input(defval=true, title='Start Strategy')
UseSl = input(defval=false, title='Use Stoploss Price')
Compound = input(defval = false ,title = "Compound Profit")
xtf = input.timeframe(title='** Fix chart to which time frame ? **)', defval='D')
//BUY
float buyLine = na
buyLine := ta.highest(high,Period)[1]
plot(showema ? buyLine : na, linewidth=1, style=plot.style_linebr, color=color.new(color.green, 0))
//SELL
output = ta.ema(close, Period)
show = request.security(syminfo.tickerid, xtf, output)
FastL = plot(showema ? show : na, color=color.new(color.white, 0), linewidth=2, title='Slow EMA')
//Buy-Sell Signal
Green = close > buyLine // Buy
Red = close < show // Sell
buycond = Green and Green[1] == 0
sellcond = Red and Red[1] == 0
bullish = ta.barssince(buycond) < ta.barssince(sellcond)
bearish = ta.barssince(sellcond) < ta.barssince(buycond)
buy = bearish[1] and buycond
sell = bullish[1] and sellcond
plotshape(MarkBuySig ? buy : na, style=shape.labelup, text='Buy Next Bar', textcolor=color.new(color.black, 0), location=location.belowbar, color=color.new(color.green, 0))
plotshape(MarkBuySig ? sell : na, style=shape.labeldown, text='Sell Next Bar', textcolor=color.new(color.black, 0), location=location.abovebar, color=color.new(color.red, 0))
bgcolor(showbg ? bullish ? color.new(color.green,90) : color.new(color.red,90) : na )
// === BACKTEST RANGE === //
use_date_range = input(true)
FromYear = input.int(defval=2012, title='From Year', minval=1950)
FromMonth = input.int(defval=1, title='From Month', minval=1)
FromDay = input.int(defval=1, title='From Day', minval=1)
ToYear = input.int(defval=9999, title='To Year', minval=1950)
ToMonth = input.int(defval=1, title='To Month', minval=1)
ToDay = input.int(defval=1, title='To Day', minval=1)
in_date_range = use_date_range ? time > timestamp(FromYear, FromMonth, FromDay, 00, 00) and time < timestamp(ToYear, ToMonth, ToDay, 23, 59) : true
//****************************************************************************//
//////////////////////////////////////////////
// define strategy entry / exit //
//////////////////////////////////////////////
//****************************************************************************//
// LONG CONDITIONS
Select_Long_Condition_1 = close > buyLine // Buy when Have Signal
Open_Long_Condition = Select_Long_Condition_1 and strategy.opentrades == 0
//****************************************************************************//
// STOP LOSS Price
float longSL = na
longSL := Open_Long_Condition ? ta.lowest(low, SLDAY)[1] : longSL[1]
//****************************************************************************//
// Cal StopLoss
Long_Entry_Price = close
Diff_OPEN_to_SL = math.abs(Long_Entry_Price - longSL)
// Exit CONDITIONS
Exit_Long_Condition = close < show // Sell when Have Signal
//****************************************************************************//
// POSITION SIZE CAP
strategy.initial_capital = 50000
float portSize = Compound ? strategy.netprofit + strategy.initial_capital : strategy.initial_capital
float LossAmoutUnit = portSize * Risk_Per_Trade //50
float PercentSL = ( Diff_OPEN_to_SL / Long_Entry_Price ) * 100
float PositionSize = LossAmoutUnit / Diff_OPEN_to_SL
//****************************************************************************//
// ENTRY/EXIT
if Buysig
if Open_Long_Condition and in_date_range
strategy.entry('LONG', strategy.long, qty=PositionSize)
if Exit_Long_Condition and in_date_range
strategy.close('LONG')
if close < longSL and UseSl
strategy.close('LONG')
//****************************************************************************//
// PLOT STOP LOSS
longPlotSL = strategy.opentrades > 0 and strategy.position_size > 0 ? longSL : na
// label.new(bar_index, high, text=str.tostring(longPlotSL),color=color.white, textcolor=color.black)
plot(longPlotSL, title="", linewidth=2, style=plot.style_linebr, color=color.new(color.red, 0))
//****************************************************************************//