
이 전략은 빠르고 느리게 움직이는 평행선의 황금 포크 사다리 원칙에 기초하여 설계되었습니다. 빠른 평행선이 아래에서 느린 평행선을 통과하면 더 많이; 빠른 평행선이 위에서 아래에서 느린 평행선을 통과하면 공백을하십시오. 이 전략은 중장선 거래에 적용되며 시장 추세의 역전을 포착 할 수 있습니다.
이 전략은 기하급수적인 이동 평균 ((EMA) 을 사용하여 빠른 평균을 계산한다. 빠른 평균은 10주기이고, 느린 평균은 30주기이다. 전략은 먼저 빠른 EMA와 느린 EMA를 계산하고, 그 다음 평균을 그리고 다른 색의 배경을 표시하여 평평선 경향 방향을 나타낸다.
오늘의 종결 가격이 빠른 평균선보다 높고 빠른 평균선이 느린 평균선보다 높으면, 녹색 배경이 표시되어 상승 추세에 있음을 나타냅니다. 오늘의 종결 가격이 빠른 평균선보다 낮고 빠른 평균선이 느린 평균선보다 낮으면, 빨간 배경이 표시되어 하락 추세에 있음을 나타냅니다.
상승 추세에서, 빨간 K선이 나타나면 ((폐쇄 가격이 오픈 가격보다 낮다) 그리고 어제도 빨간 K선이 나타나면, 더 많은 입장을 한다. 중지 손실 지점을 300점으로 설정하고, 정지점을 평정 위치에 공백한다.
하향 트렌드 하에서, 녹색 K 라인이 나타나면 (폐쇄 가격이 개장 가격보다 높다) 그리고 어제도 녹색 K 라인이 나타나면, 상장한다. 중지 손실 지점을 300점으로 설정하고, 정지점을 평정 지점에 더 많이 한다.
각 거래 방향에 대해 포지션을 열고, 1008000000 밀리 초 (약 2 주) 이상 포지션을 보유하면, 포지션을 필연적으로 평정하여 사다리를 방지한다.
이 전략은 전체적으로 균형이 맞으며, 이중 EMA를 사용하여 트렌드를 식별하고, K선 엔티티와 부가 규칙을 결합하여 거래를 할 수 있으며, 가짜 신호를 효과적으로 필터링 할 수 있습니다. 그러나 EMA 시스템과 파라미터 설정은 여전히 최적화해야하며, 손해 차단 메커니즘은 시장에 따라 조정해야하며, 전체적으로 신뢰할 수있는 트렌드 거래 전략입니다.
/*backtest
start: 2023-10-10 00:00:00
end: 2023-11-09 00:00:00
period: 1h
basePeriod: 15m
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/
// © yeainshukla
//@version=5
strategy('BuyRedSellGreen4H', overlay = true)
greenCandle = close > open
redCandle = open > close
start = timestamp(2023,9,18,0,00)
end = timestamp(2023,12,31,0,00)
fastLength = input.int(10, title="Fast Average Length")
slowLength = input.int(30, title="Slow Average Length")
averageData = input.source(close, title="Average Data Source")
// Calculate exponential moving averages
fastAverage = ta.ema(averageData, fastLength)
slowAverage = ta.ema(averageData, slowLength)
// Plot averages
plot(fastAverage, color=color.navy, title="Fast EMA")
plot(slowAverage, color=color.fuchsia, linewidth=2, title="Slow EMA")
// Show the moving average trend with a coloured background
backgroundColor = if close > fastAverage and fastAverage > slowAverage
color.new(color.green, 85)
else if close < fastAverage and fastAverage < slowAverage
color.new(color.red, 85)
else
color.new(color.orange, 90)
bgcolor(backgroundColor, title="EMA Background")
if time >= start and time < end
if(close < open)
if(close[1] < open[1])
strategy.entry("Enter Long", strategy.long)
strategy.exit("Exit Long", from_entry="Enter Long")
strategy.close("Enter Short")
else
if(close[1] > open[1])
strategy.entry("Enter Short", strategy.short)
strategy.exit("Exit Short", from_entry="Enter Short")
strategy.close("Enter Long")
if strategy.position_size < 0 or strategy.position_size > 0// short and long is opened.
if((time - strategy.opentrades.entry_time(strategy.opentrades - 1)) > 1008000000)
strategy.close("Enter Short")
strategy.close("Enter Long")