이 전략은 기술적인 지표에 기반한 간단한 자동 다단계 트렌드 전략으로, 비트코인과 이더리움과 같은 암호화폐에 적용되며, 주요 상승세를 포착하고, 빈번한 거래로 인한 수수료 손실을 줄이기 위한 것이다.
MACD를 사용하여 트렌드 방향을 판단합니다. MACD는 위쪽으로 갈 때 더 많이 보입니다.
20주기 EMA, 100주기 SMA, 200주기 SMA를 계산하고 EMA와 SMA는 상향으로 올라갈 때 더 많이 볼 수 있습니다.
EMA가 SMA보다 높을 때 더 많이 구매하고, SMA가 SMA의 느린 선보다 높을 때 더 많이 구매합니다.
스톱로스 라인을 설정하고, 가격이 스톱로스 라인을 넘으면 스톱로스를 종료한다.
가격이 하락할 때 EMA 아래 SMA를 통과할 때 평점 퇴출한다.
이 전략은 트렌드와 출입 시기를 판단하는 여러 지표를 통합하여 주요 상승 추세를 추적하여 수익을 얻습니다.
여러 지표의 조합으로 판단하여, 가짜 돌파구와 같은 잘못된 신호를 효과적으로 필터링할 수 있습니다.
트렌드가 뚜렷한 상태에서만 입점하면 불필요한 거래가 줄어들고 거래 빈도가 낮아집니다.
단편 거래의 최대 손실을 효과적으로 통제할 수 있는 HST 전략;
“비트코인과 이더리움에서 더 나은 수익을 얻을 수 있다는 것을 보여준다”.
전략 논리는 간단하고 명확하며, 이해하기 쉬운 구현, 초보자 학습에 적합하다.
확장성이 강하여 더 많은 지표를 도입하여 최적화 할 수 있습니다.
시장의 움직임이 무작위적일 수 있고, 잘못된 판단의 위험이 있습니다.
단독 포지션으로 시스템적 위험을 회피할 수 없습니다.
부적절한 스톱포인트 설정으로 인해 과도한 스톱포인트 손실이 발생할 수 있습니다.
이 자료는 실제 실적을 나타내지 않으며, 실적은 검증되지 않았습니다.
거래 비용의 영향을 고려하지 않고, 실 디스크 효과는 다를 수 있습니다.
다양한 품종의 특성을 고려하지 않고, 최적화를 조정해야 합니다.
다양한 변수 조합을 테스트하고, 지표 변수를 최적화합니다.
KDJ와 같은 지표가 들어오는 신호를 필터링하는 것을 추가합니다.
“다이나믹 스톱”을 도입하여 손해 중지 전략을 최적화합니다.
계좌 자금 관리를 고려하고 포지션 크기를 조정합니다.
종의 특징을 구분하고, 변수를 조정합니다.
더 많은 시간 주기의 지표와 함께 판단하는 것;
다양한 품종의 효과를 테스트하여 가장 좋은 품종을 찾아보세요.
이 전략의 전체적인 아이디어는 명확하고 이해하기 쉽고, 다중 지표 판단을 사용하여 오류 신호를 효과적으로 필터링 할 수 있습니다. 그러나 여전히 추가적인 최적화 파라미터, 위험 제어 등이 필요하며, 실장 검증과 결합하면 실제 적용이 가능합니다. 최적화를 추가로 확장하면 매우 실용적인 암호화폐 트렌드 추적 전략이 될 수 있습니다.
/*backtest
start: 2023-09-06 00:00:00
end: 2023-10-06 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy(title="BTC Long strategy", overlay=true, max_bars_back=3000, initial_capital=1000, commission_value=0.075)
//////////// !!!!!!!!!!!!!!!! WORK BEST IN 2 HOURS for BTC, ETH and ETHXBT !!!!!!!!!!!!!!!!!!! /////////////////////
[macdLine, macdSignalLine, macdHist] = macd(close, 12, 26, 7)
//_rsi_len = input(14, title="RSI length")
_rsi_len = 14
NewValue = 0
PreviousValue = 0
leverage = 1
smaPercentageIncrease = 0.0
SMA_PERCENT_INCREASE = 0.0
float atrValue = 0
bool bPositionOpened = false
float stockPositionSize = 0
float volatilityPercentage = 0.0
bool bDisplayArrow = false
bool bEMAIsRising = false
bool bSMAIsRising = false
bool bSMASlowIsRising = false
bool bMACDIsRising = false
bool bMACDHistIsRising = false
bool bMACDSignalIsRising = false
float stopLoss = input (1.5, "StopLoss in %", type=input.float) //StopLoss associated with the order
//positionSize = input (1000, "in $")
float positionSize = 1000
float currentPrice = close
float stopLossPrice = 0
float entryPrice = 0
//-----------------------------------------------------------
// === INPUT BACKTEST RANGE ONE YEAR
//FromDay = input(defval = 01, title = "From Day", minval = 1, maxval = 31)
//FromMonth = input(defval = 01, title = "From Month", minval = 1, maxval = 12)
//FromYear = input(defval = 2020, title = "From Year", minval = 2017)
FromDay = 01
FromMonth = 01
FromYear = 2019
//ToDay = input(defval = 01, title = "To Day", minval = 1, maxval = 31)
//ToMonth = input(defval = 01, title = "To Month", minval = 1, maxval = 12)
//ToYear = input(defval = 2023, title = "To Year", minval = 2017)
ToDay = 31
ToMonth = 12
ToYear = 2099
// === FUNCTION EXAMPLE ===
start = timestamp(FromYear, FromMonth, FromDay, 00, 00) // backtest start window
finish = timestamp(ToYear, ToMonth, ToDay, 23, 59) // backtest finish window
window() => true // create function "within window of time"
//emaLength = input(20, "EMA Length")
//smaLength = input(100, "SMA Length")
//smaSlowLength = input(200, "SMA Length")
emaLength = 20
smaLength = 100
smaSlowLength = 200
ema = ema(close, emaLength)
sma = sma(close, smaLength)
smaSlow = sma(close, smaSlowLength)
plot(sma, color=color.green)
plot(smaSlow, color=color.orange)
plot(ema, color=color.yellow)
//reload previous values
stopLossPrice := na(stopLossPrice[1]) ? 0.0 : stopLossPrice[1]
entryPrice := na(entryPrice[1]) ? 0.0 : entryPrice[1]
bPositionOpened := na(bPositionOpened[1]) ? false : bPositionOpened[1]
positionSize := na(positionSize[1]) ? 50000 : positionSize[1]
stockPositionSize := na(stockPositionSize[1]) ? 0 : stockPositionSize[1]
//leverage := na(leverage[1]) ? 1 : leverage[1]
//ReEvaluate the direction of indicators
bEMAIsRising := rising(ema, 2)
bSMAIsRising := rising(sma, 3)
bMACDIsRising := rising(macdLine, 3)
bMACDHistIsRising := rising(macdHist, 1)
bSMASlowIsRising := rising(smaSlow, 10)
bMACDSignalIsRising := rising(macdSignalLine, 3)
atrValue := atr(14)
volatilityPercentage := (atrValue/currentPrice)*100 //calcute the volatility. Percentage of the actual price
//There is too many signal in tranding market, to avoid this we need to make sure that the smaSlow has a mininal increase
//THIS DOES NOT WORK AT ALL!!!!!
//if bSMASlowIsRising == true
// //calculate the percentegage difference over the last 10 bars
// smaPercentageIncrease := ((smaSlow[0]/sma[10])-1)*100
// if smaPercentageIncrease < SMA_PERCENT_INCREASE
// //Not enough increase we reset the flag
// bSMASlowIsRising := false
if (window())
//Check if we can open a LONG
//sma > smaSlow and
if ( volatilityPercentage < 2 and bPositionOpened == false and bSMASlowIsRising == true and bMACDIsRising == true and bEMAIsRising == true and bSMAIsRising == true and ema[0] > sma[0] and sma[0] < currentPrice)
// add comparaison between macd and macd signal line
//if (bPositionOpened == false and macdSignalLine < macdLine and bMACDIsRising == true and bMACDHistIsRising == true and bEMAIsRising == true and bSMAIsRising == true and ema[1] > sma[1] and sma[1] < currentPrice)
//Enter in short position
stockPositionSize := (positionSize*leverage)/currentPrice //Calculate the position size based on the actual price and the position Size (in $) configured.
//calculate exit values
stopLossPrice := currentPrice*(1-stopLoss/100)
strategy.entry("myPosition", strategy.long, qty=stockPositionSize, comment="BUY at " + tostring(currentPrice))
entryPrice := currentPrice //store the entry price
bPositionOpened := true
bDisplayArrow := true
//if (bPositionOpened == true and (currentPrice <= stopLossPrice or crossunder(ema[1], sma[1]) or currentPrice < sma[1]))
if (bPositionOpened == true and (currentPrice <= stopLossPrice or crossunder(ema[1], sma[1])))
strategy.close("myPosition", comment="" + tostring(currentPrice) ) //Stop
//uncomment the below line to make the bot investing the full portfolio amount to test compounding effect.
//positionSize := positionSize + ((stockPositionSize * currentPrice) - (positionSize*leverage))
//reset some flags
bPositionOpened := false
bDisplayArrow := true
entryPrice := 0.0