この戦略は,高点と低点の単純な移動平均を計算し,現在の閉盘価格と対比して買いと売却のタイミングを判断する.その目的は,価格が平均線を突破するシグナルを捕捉して,トレンドの早期のチャンスを得ることである.
平均移動は,平均移動は,平均移動は,平均移動は,
平均移動は,平均移動は,平均移動は,平均移動は,
閉盤が高点平均線を突破すると,追加入場を行う
閉店価格が低点平均線を突破したときに空白入場
固定ストップとストップストップ戦略を用いたリスク管理
シンプルで分かりやすい指標を用いて実現
価格が平均線を突破する信号を捕捉する
音の部分を素早くフィルターし,トレンドを認識します.
戦略の運用コストを削減する計算量
拡大のための適性に基づく戦略
合理的なパラメータを設定し,過度に敏感にならないようにする.
大規模な突破の危険に 対処できない
リスクは,ある程度あります.
自動で停止停止位置を調整できない
トレンドの背景の長さは判り難い
異なるパラメータが信号品質に与える影響をテストする
突破の有効性を保証するフィルタリング条件を追加する
トレンド分析を組み合わせて,騙されないようにする
ダイナミック・ストップ・ストップ・ストラトジーを開発する
戦略の勝利率を向上させる
異なるサイクルで戦略の強さをテストする
この戦略は,簡単な指標を研究して価格動力を判断し,基本的トレンド取引の考えを与えます.パラメータ最適化,リスク管理などと連携してさらに完善され,取引ロジックは拡張性があり,比較的安定した量化システムに発展できます.全体的に,この戦略は,操作が簡単で,量化取引の入門戦略として適しています.
/*backtest
start: 2023-09-11 00:00:00
end: 2023-09-13 00:00:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy("HiLo", overlay=true)
// Testing a specific period
testStartYear = input(2017, "Backtest Start Year")
testStartMonth = input(4, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
testStopYear = input(2017, "Backtest Stop Year")
testStopMonth = input(5, "Backtest Stop Month")
testStopDay = input(1, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)
// A switch to control background coloring of the test period
testPeriodBackground = input(title="Color Background?", type=bool, defval=true)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FF00 : na
bgcolor(testPeriodBackgroundColor, transp=97)
testPeriod() =>
time >= testPeriodStart and time <= testPeriodStop ? true : false
//HiLo Strategy
length = input(4, minval=0)
displace = input(0, minval=0)
highsma = sma(high, length)
lowsma = sma(low, length)
longCondition = close > highsma[displace]
if (longCondition)
strategy.entry("long", true)
shortCondition = close < lowsma[displace]
if (shortCondition)
strategy.entry("short", false)
// Exit seems with a problem. it keeps saying the order's limit (2000) was reached even if I back test it just for a day.
// If the two lines bellow are commented, then it it works. Anyone? Any idea what's wrong?
// strategy.exit("exit", "long", profit=10, loss=5)
// strategy.exit("exit", "short", profit=10, loss=5)