이 전략은 기본 이동 일률 시스템으로, 신호 출력 후 특정 입구 시점에 대해 최적화되었다.
이 논리는 다음과 같습니다.
특정 주기 (예: 20일) 의 이동 평균을 계산합니다.
가격 상승 시에는 다중 신호가 발생하고, 하락 시에는 공백 신호가 발생한다.
신호를 받고 즉시 진입하지 않고 더 나은 가격을 기다립니다.
특정 기간 (예: 3일) 동안 더 나은 가격이 발생하면 입점합니다.
만약 그렇지 않다면, 5일에는 상장 가격으로 상장하세요.
이 전략은 신호를 내놓은 후 서둘러 진입하는 것이 아니라, 정리된 후 다시 트렌드를 시작하는 기회를 찾아서 더 좋은 가격으로 포지션을 구축할 수 있다.
진입 최적화, 더 나은 진입 포인트를 얻기 위한 노력
최대 대기일 수를 설정하여 놓치지 마십시오.
규칙은 간단하고 명확하며 실행하기 쉽습니다.
대기 시간 및 값은 반복 테스트 및 최적화를 필요로 합니다.
짧은 트렌드의 일부 기회를 놓쳤을 수도 있습니다.
시간과 가격이라는 이중 조건에 주의를 기울여야 합니다.
이 전략은 간단한 입장을 최적화하여 트렌드를 놓치지 않는 것을 보장하는 조건에서 더 나은 입문 지점을 얻습니다. 그러나 대기 시간 및 입문 조건을 최적화하는 것은 전략의 효과에 중요합니다.
/*backtest
start: 2023-08-14 00:00:00
end: 2023-09-13 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/
// © dongyun
//@version=4
strategy("等待一个更好的入场机会", overlay=true)
period = input(20,'')
maxwait = input(3,'')
threshold = input(0.01,'')
signal = 0
trend = 0.0
newtrend = 0.0
wait = 0.0
initialentry = 0.0
trend := sma(close,period)
signal := nz(signal[1])
if trend > nz(trend[1])
signal := 1
else
if trend < nz(trend[1])
signal := -1
wait := nz(wait[1])
initialentry := nz(initialentry[1])
if signal != signal[1]
if strategy.position_size > 0
strategy.close('long',comment='trend sell')
signal := -1
else
if strategy.position_size < 0
strategy.close('short',comment='trend buy')
signal := 1
wait := 0
initialentry := close
else
if signal != 0 and strategy.position_size == 0
wait := wait + 1
// test for better entry
if strategy.position_size == 0
if wait >= maxwait
if signal > 0
strategy.entry('long',strategy.long, comment='maxtime Long')
else
if signal < 0
strategy.entry('short',strategy.short, comment='maxtime Short')
else
if signal > 0 and close < initialentry - threshold
strategy.entry('long',strategy.long, comment='delayed Long')
else
if signal < 0 and close > initialentry + threshold
strategy.entry('short',strategy.short, comment='delayed short')