
이 전략은 간단한 이동 평균을 기반으로 한 크로스 메이어 라인 역전 전략이다. 그것은 길이 1과 길이 5의 간단한 이동 평균을 사용한다. 짧은 기간의 이동 평균이 아래에서 긴 기간의 이동 평균을 통과 할 때 더 많은 것을 하고, 위에서 아래로 통과 할 때 공백을 하고, 전형적인 트렌드 추적 전략이다.
이 전략은 클로즈 가격의 1일 간단한 이동 평균 sma1과 5일 간단한 이동 평균 sma5를 계산하여 sma1 위에 sma5를 착용할 때 더 많은 입장을 취하고 sma1 아래 sma5를 착용할 때 더 많은 입장을 취합니다. 추가한 후 중지 손실은 입문 가격 아래 5 달러, 입문 가격 위 150 달러; 입문 가격 위 5 달러, 입문 가격 아래 150 달러로 중지 손실을 설정합니다.
최적화 방향:
이 전략은 간단한 쌍평선 전략으로, 동작이 간단하고 구현이 쉬운 특징을 가지고 있으며, 전략 아이디어를 빠르게 검증할 수 있다. 그러나 그것의 견딜 능력과 수익 공간은 상대적으로 제한되어 있으며, 더 많은 시장 환경에 적응하도록 파라미터와 필터 조건에 대한 최적화가 필요하다. 초보자 최초의 정량화 전략으로서, 기본적인 구성 요소를 포함하고 있으며, 간단한 프레임 워크로 반복적으로 개선할 수 있다.
/*backtest
start: 2023-02-19 00:00:00
end: 2024-02-19 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Valeria 181 Bot Strategy Mejorado 2.21", overlay=true, margin_long=100, margin_short=100)
var float lastLongOrderPrice = na
var float lastShortOrderPrice = na
longCondition = ta.crossover(ta.sma(close, 1), ta.sma(close, 5))
if (longCondition)
strategy.entry("Long Entry", strategy.long) // Enter long
shortCondition = ta.crossunder(ta.sma(close, 1), ta.sma(close, 5))
if (shortCondition)
strategy.entry("Short Entry", strategy.short) // Enter short
if (longCondition)
lastLongOrderPrice := close
if (shortCondition)
lastShortOrderPrice := close
// Calculate stop loss and take profit based on the last executed order's price
stopLossLong = lastLongOrderPrice - 5 // 10 USDT lower than the last long order price
takeProfitLong = lastLongOrderPrice + 151 // 100 USDT higher than the last long order price
stopLossShort = lastShortOrderPrice + 5 // 10 USDT higher than the last short order price
takeProfitShort = lastShortOrderPrice - 150 // 100 USDT lower than the last short order price
// Apply stop loss and take profit to long positions
strategy.exit("Long Exit", from_entry="Long Entry", stop=stopLossLong, limit=takeProfitLong)
// Apply stop loss and take profit to short positions
strategy.exit("Short Exit", from_entry="Short Entry", stop=stopLossShort, limit=takeProfitShort)