この戦略は,基本の移動均線システムに基づいて,信号発射後の特定の入場時刻に最適化されている.
論理的に言うと
移動平均を一定周期 (例えば20日) で計算する.
価格が平均線を上るときは多信号,下るときは空信号を生成する.
信号を受け取るとすぐに入場せず,よりよい価格を待つ
指定された数日間 (例えば3日) の間に優遇価格が出た場合,入場
5日目には閉店価格で入場し,見逃さないようにしましょう.
この戦略は,信号を発した後に急いで入場するのではなく,収束後にトレンドの再開の機会を探し,より良い価格でポジションを確立する.
ランキングの優位化,入場ポイントの獲得
待ち時間を最大に設定して,見逃さないでください.
規則はシンプルで明確で 実行しやすい
待ち時間と値は繰り返しテストと最適化が必要
ショートライントレンドの機会を逃したかもしれない
タイムと価格の2つの条件に注意を向ける
この戦略は,簡単な入場を最適化することで,トレンドを逃さないことを前提に,よりよい入場ポイントを獲得する.しかし,待ち時間と入場条件を最適化することは,戦略の効果に不可欠である.
/*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')