
이것은 5일 이동 평균 ((MA5)) 에 기반한 쌍평평선 교차 포지션 개시 전략이다. 이 전략의 주요 아이디어는: MA5 위 또는 아래에서 일정 거리에서 포지션을 개시하고, 폐쇄 가격이 개시 가격보다 높을 때 또는 개시 가격으로 돌아갈 때 평점. 이 전략은 단기 경향을 포착하면서 위험을 제어하는 것을 목표로 한다.
이 전략은 5일 간단한 이동 평균 ((SMA) 을 주요 지표로 사용한다. 신규 차트 개시 거래 가격이 MA5보다 높을 때 구매 시나리오를 실행한다. 신규 차트 개시 거래 가격이 MA5보다 낮고 MA5에서 0.002 포인트 이상 떨어져 있을 때 구매 시나리오를 실행한다. 판매 조건에 대해, 개시 거래 가격이 개시 거래 평균 가격보다 높거나 개시 거래 평균 가격과 같을 때 판매 시나리오를 실행한다. 개시 거래 가격이 개시 거래 평균 가격보다 0.1% 낮을 때 판매 시나리오를 실행한다.
이 쌍평평선 교차 포지션 개시 전략은 단기 트렌드에 기반한 간단한 전략이다. MA5의 상하로 통과하고, 그리고 절댓값의 거리를 설정하여, 단기 트렌드 기회를 잡을 수 있다. 동시에, 고정 비율의 손실은 위험을 제어할 수 있다. 그러나 이 전략에는 단일 지표에 의존하는 것, 빈번한 거래 등과 같은 몇 가지 제한이 있다.
/*backtest
start: 2023-04-24 00:00:00
end: 2024-04-29 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("YBS Strategy 1.1", overlay=true)
// Moving Average Settings
ma5 = ta.sma(close, 5)
// Scenario 1: Buy when a new candle opens above the MA5
buy_condition_scenario1 = open > ma5
// Scenario 2: Buy when a new candle opens below the MA5 and is at a significant distance from the MA5
distance_from_ma5 = open - ma5
buy_condition_scenario2 = open < ma5 and distance_from_ma5 > 0.002 // Define distance in points here
// Sell: Sell at the close of the candle if it's positive above the entry price, or if the price returns to the entry price
sell_condition_scenario1 = close > strategy.position_avg_price or close == strategy.position_avg_price
sell_condition_scenario2 = close <= strategy.position_avg_price * 0.999 // Close if price drops more than 0.1% from entry price
// Execute buy and sell orders
if (buy_condition_scenario1 and not (strategy.opentrades > 0))
strategy.entry("Buy Scenario 1", strategy.long)
if (buy_condition_scenario2 and not (strategy.opentrades > 0))
strategy.entry("Buy Scenario 2", strategy.long)
if (sell_condition_scenario1)
strategy.close("Buy Scenario 1")
if (sell_condition_scenario2)
strategy.close("Buy Scenario 2")