
이 전략은 SMA 지표에 기반한 간단한 다공간 전략을 구축한다. 가격이 20주기 높은 SMA를 넘으면 더 많은 것을 하고, 가격이 20주기 낮은 SMA를 넘으면 더 많은 것을 하지 않는다. 동시에 손실 퇴출 메커니즘을 설정한다.
이 전략은 20주기의 가장 높은 가격과 가장 낮은 가격의 SMA를 다채로운 지표로 사용합니다. 가격이 가장 높은 SMA를 통과했을 때, 현재 상승 추세에 있다고 생각하면 더 많은 돈을 벌 수 있습니다. 가격이 가장 낮은 SMA를 넘어서는 경우 현재 하향 추세에 있다고 생각하면 더 많은 돈을 벌 수 있습니다.
구체적으로, 전략은 20주기highest 최고 가격과lowest 최저 가격의 SMA를 먼저 계산하고, 지표선을 그립니다. 그리고 다음 거래 논리를 설정합니다:
다중 입점: 상위 SMA를 통과한 경우 다수 출전: 마감 가격 0.99배highest SMA 아래로
공짜로 입시: 폐막 가격 아래로 LOWEST SMA를 돌파할 때
공짜 출장: 1.01배로 LOWEST SMA를 마감할 때
이런 식으로 트렌드를 따라가는 다공간 전략이 만들어집니다.
이 전략은 다음과 같은 장점이 있습니다.
이 전략에는 위험도 있습니다.
다른 지표와 결합하여 이러한 위험을 제어하고 줄일 수 있습니다.
이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.
이 전략의 전체적인 아이디어는 명확하고, 구현하기 쉽다. SMA 지표를 통해 공허 경향을 판단하고, 합리적인 진입 및 퇴출 메커니즘을 설정하면 좋은 효과를 얻을 수 있다. 추가적인 최적화 공간이 있으며, 다른 지표와 기법과 함께하면, 장기적으로 추적할 가치가 있는 좋은 잠재력을 가진 전략이 될 수 있다.
/*backtest
start: 2023-11-14 00:00:00
end: 2023-11-21 00:00:00
period: 10m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AlanAntony
//@version=4
strategy("ma 20 high-low",overlay=true)
//compute the indicators
smaH = sma(high, 20)
smaL = sma(low, 20)
//plot the indicators
plot(smaH,title="smaHigh", color=color.green, linewidth=2)
plot(smaL,title="smaLow", color=color.red, linewidth=2)
//trading logic
enterlong = crossover(close,smaH) //positive ema crossover
exitlong = crossunder(close,0.99*smaH) //exiting long
entershort = crossunder(close,smaL) //negative EMA Crossover
exitshort = crossover(close,1.01*smaH) //exiting shorts
notintrade = strategy.position_size<=0
bgcolor(notintrade ? color.red:color.green)
//execution logic
start = timestamp(2015,6,1,0,0)
//end = timestamp(2022,6,1,0,0)
if time >= start
strategy.entry( "long", strategy.long,1, when = enterlong)
strategy.entry( "short", strategy.short,1, when = entershort)
strategy.close("long", when = exitlong)
strategy.close("short", when = exitshort)
//if time >= end
// strategy.close_all()