日々の終値比較に基づく定量取引戦略


作成日: 2023-11-21 14:34:11 最終変更日: 2023-11-21 14:34:11
コピー: 0 クリック数: 782
1
フォロー
1617
フォロワー

日々の終値比較に基づく定量取引戦略

概要

この戦略は,日線閉店価格比較戦略と呼ばれ,日線閉店価格に基づいて取引決定を行う量的な戦略である.この戦略は,現在の日線閉店価格と前日の日線閉店価格の差値を計算することによって取引シグナルを生成する.差値が設定された値を超えると,購入または販売を行う.

戦略原則

この戦略の核心的な論理は,現在のK線の終了価格と,前のK線の終了価格の比較である.

  1. 現在の日線閉店価格と前日の日線閉店価格の差を計算する (today - yesterday)
  2. 差値と前日の閉店価格の比率を計算します.
  3. 割合が設定された正の値より大きい場合,買い込み信号が発生し,比例が設定された負の値より小さい場合,売り込み信号が発生します.
  4. シグナルで入ると多量または空の倉庫位置

この戦略は,止損と停止条件を設定せず,値条件によって形成される取引信号による入場と平和のポジションを行う.

優位分析

  • シンプルで分かりやすい考え方で,量子取引の入門学習に適しています.
  • 日経の終盤価格のみをベースに取引し,頻繁に取引を避ける
  • 値下げを調整することで取引頻度を制御できます.

リスク分析

  • 単一損失をコントロールできない
  • 連続した取引信号が起こり,過剰取引が起こる可能性があります.
  • 総損失を十分にコントロールできない.

最適化の方向

  • ストップロズロジクスを追加し,単一損失を制御します.
  • ポジション開設制限を高め,過剰取引を避ける
  • パラメータを最適化し,最適な取引頻度を見つけます.

要約する

この戦略は,日経の閉盘価格を比較して取引信号を形成する.考え方はシンプルで,入門学習に適している.しかし,この戦略には一定のリスクがあり,実際の取引のためにさらなる最適化が必要である.

ストラテジーソースコード
/*backtest
start: 2022-11-14 00:00:00
end: 2023-11-20 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("Daily Close Comparison Strategy (by ChartArt) correct results", shorttitle="CA_-_Daily_Close_Strat", overlay=false)

// ChartArt's Daily Close Comparison Strategy
//
// Version 1.0
// Idea by ChartArt on February 28, 2016.
//
// This strategy is equal to the very
// popular "ANN Strategy" coded by sirolf2009,
// but without the Artificial Neural Network (ANN).
//
// Main difference besides stripping out the ANN
// is that I use close prices instead of OHLC4 prices.
// And the default threshold is set to 0 instead of 0.0014
// with a step of 0.001 instead of 0.0001.
//
// This strategy goes long if the close of the current day
// is larger than the close price of the last day.
// If the inverse logic is true, the strategy
// goes short (last close larger current close).
//
// This simple strategy does not have any
// stop loss or take profit money management logic.
//
// List of my work: 
// https://www.tradingview.com/u/ChartArt/
// 
//  __             __  ___       __  ___ 
// /  ` |__|  /\  |__)  |   /\  |__)  |  
// \__, |  | /~~\ |  \  |  /~~\ |  \  |  
// 
// 

threshold = input(title="Price Difference Threshold correct results", type=float, defval=0, step=0.004)

getDiff() =>
    yesterday=request.security(syminfo.tickerid, 'D', close[1])
    today=close
    delta=today-yesterday
    percentage=delta/yesterday
    
closeDiff = getDiff()
 
buying = closeDiff > threshold ? true : closeDiff < -threshold ? false : buying[1]

hline(0, title="zero line")

bgcolor(buying ? green : red, transp=25)
plot(closeDiff, color=silver, style=area, transp=75)
plot(closeDiff, color=aqua, title="prediction")

longCondition = buying
if (longCondition)
    strategy.entry("Long", strategy.long)

shortCondition = buying != true
if (shortCondition)
    strategy.entry("Short", strategy.short)