SF34 | Stock Index Day Trading Strategy (Development Post)

 

Hello everyone, I am Ukrainian Juggernaut.

In this issue, we develop an intraday strategy for a stock index. In order to adapt to the multi-platform source code, we write it based on the closing price mechanism. The closing price model has both advantages and disadvantages. If your cycle is relatively large, such as more than 15 minutes, the entry and exit signals at the daily level will have a relatively large lag. However, for the level below 5 minutes, the short-term trading model has no obvious lag, and can filter some burrs and needles.

Feature one:

The stock index trades for 4 hours a day and there is no night trading. The trading time is short, the handling fee is expensive, and frequent entry and exit may not lead to good returns. The most important thing is to seize a band in the day, that is, the fattest and most beautiful fish market.

Feature two:

Poor continuity, stock index gaps are a frequent occurrence. Excessive gaps have basically digested market expectations, and the trend throughout the day is likely to be sideways or reverse. Entering the market immediately after the big gap is not a wise choice, on the contrary, it will take a greater risk.

Introduction:

Applicable period: 3 minutes

Applicable varieties: IF888, IH888, IC888

Fee slip: Default firm fee, 1 slip in each direction

Note: The native variety of the strategy is IF, and the other two stock indices suggest that you readjust the parameters yourself

principle:

Trading conditions are formulated for the above characteristics:

  1. Closing Clearance

  2. VWAP intraday volume moving average

  3. Judging major-level trends across cycles

  4. Strong and weak filtering

    5. Appearance conditions

    6. Gap market filtering

VWAP intraday volume moving average

We know that the use of VWAP is at the micro and macro levels. In this issue, we use the micro-level algorithm to help us implement the strategy, which is calculated by the following formula:

Volume-weighted average price, the above formula is the sum of the product of each transaction volume in N cycles * the sum of the products of each transaction price/sum of transaction volume in N cycles.

Simple Arithmetic Average (MA), Exponential Moving Average (EMA), Weighted Arithmetic Moving Average (SMA), these moving averages are calculated in different ways and have different smoothing effects, but they are only two-dimensional compositions of price and time , there is essentially no difference. The volume-weighted average price (VWAP) is different. It takes the volume, the most important factor in calculating the cost price, into account, and the obtained cost price is more convincing than other moving averages.

As shown in the figure, the intraday volume moving average is OK, which is mainly to help determine the intraday trend.

Judging major-level trends across cycles

The TB forum previously had a case where the code implements the cross-cycle, we can use it directly:

Mtsummation

ParamsSeries<Numeric> Price(1);Series<Numeric> BarCnt(0);Numeric Length(10);VarsSeries<Numeric> SumValue(0);Numeric i; Numeric j(0);BeginSumValue = 0;For i = 1 to Length{
   
   If (Price[j] <> InvalidNumeric){
   
   SumValue = SumValue + Price[j];j = j + BarCnt[j];}else Break;}Return SumValue;End

Mtbar (cross-period Bar line)

ParamsNumeric TimeFrame(1440);    // 目标时间周期:月线=40320,周线=10080,日线=1440,4小时线=240// 其他1小时内的周期等于相应的分钟数,如:1小时=60, 30分钟=30。。。// 支持不规则分钟数,如3分钟,8分钟,之类都行
Numeric BarsBack(1); // 目标时间周期BAR偏移:// 1--表示将目标时间周期下的前1根K线数据作为与当前Bar对应的目标时间周期下的K线数据// 0--表示将目标时间周期下的截止到目前为止的数据转换为与当前BAR对应的目标时间周期下K线数据
NumericRef oCurBar;                 // 目标时间周期下的Bar索引NumericRef oOPenHT;         // 目标时间周期下的开盘价NumericRef oHighHT;         // 目标时间周期下的最高价NumericRef oLowHT;          // 目标时间周期下的最低价NumericRef oCloseHT;        // 目标时间周期下的收盘价NumericRef oVolHT;          // 目标时间周期下的成交量NumericRef oOpenIntHT;      // 目标时间周期下的持仓量
VarsSeries<Numeric> barCnt;Series<Numeric> CurBar;Series<Numeric> barCntSum;Series<Numeric> OpenHT;Series<Numeric> HighHT;Series<Numeric> LowHT;Series<Numeric> CloseHT;Series<Numeric> VolHT;Series<Numeric> OpenIntHT;Numeric CurTime;Numeric PreTime;bool condition(false);Numeric i;BeginIf (TimeFrame == 40320)                 // 月线{
   
   CurTime = Month;PreTime = Month[1];}Else If (TimeFrame == 10080)                        // 周线{
   
   CurTime = IntPart(DateDiff(19700105,Date)/7);PreTime = IntPart(DateDiff(19700105,Date[1])/7);}Else                                                                        // 其他时间周期{
   
   CurTime = IntPart((DateDiff(19700105,date)*1440 + Hour*60 + Minute)/TimeFrame);PreTime = IntPart((DateDiff(19700105,date[1])*1440 + Hour[1]*60 + Minute[1])/TimeFrame);} condition = CurTime != PreTime;
If (CurrentBar==0)                // 如果是第一根Bar, CurBar=0{
   
   barCnt = 0;CurBar = 0;OpenHT = Open;HighHT = High;LowHT = Low;CloseHT = Close;VolHT = Vol;OpenIntHT = OpenInt;}Else{
   
   If(Condition)                // 如果在目标周期下,属于另一根K线,则CurBar加1{
   
   barCnt = 1;CurBar = CurBar[1] + 1;OpenHT = Open;HighHT = High;LowHT = Low;VolHT = Vol;}Else// 如果在目标周期下,属于同一根K线,则CurBar不变,但最高价和最低价要记录价格的变化,成交量要累加{
   
   barCnt = barCnt[1] + 1;CurBar = CurBar[1];OpenHT = OpenHT[1];HighHT = Max(HighHT[1],High);LowHT = Min(LowHT[1],Low);VolHT = VolHT[1] + Vol;}// 收盘价和持仓量总是取最新值CloseHT = Close;OpenIntHT = OpenInt;}
// 上面的程序,在每根小周期的K线上,记录了它所属的大时间周期下的开高低收等值的变化。// 接下来,要把在大的时间周期级别上,属于同一根K线的开高低收这些数据,记录在这一组小周期K线的最后一根上。barCntSum = barCnt ;If(BarsBack == 0)// 如果Bar偏移参数为0,则取每根小周期K线上保留的大时间周期截止到这根小周期K线为止的BAR数据{
   
   barCntSum = 0 ;}Else If(BarsBack == 1)// 如果Bar偏移参数为1,则取大时间周期的上一根K线的BAr数据{
   
   barCntSum = barCnt ;}Else// 如果BAR偏移参数为其他,则取大时间周期的指定偏移后的那根K线的BAR数据{
   
   For i = 2 To BarsBack{
   
   barCntSum = barCntSum + barCnt[barCntSum];}}
// 最后将相应的K线数据作为引用参数返回oCurBar = CurBar;oOpenHT = OpenHT[barCntSum];oHighHT = HighHT[barCntSum];oLowHT = LowHT[barCntSum];oCloseHT = CloseHT[barCntSum];oVolHT = VolHT[barCntSum];oOpenIntHT = OpenIntHT[barCntSum];Return barCnt;End

Mtma (cross-period moving average)

ParamsNumeric TimeFrame(1440);        // 目标时间周期参数,参数说明参见MtBarNumeric BarsBack(1);                // 目标时间周期BAR偏移参数,说明见MtBar函数Numeric Length(10);                        // 均线周期NumericRef oMA;             // 以目标时间周期下的K线数据计算出的移动平均线VarsSeries<Numeric> mtBarCnt; Series<Numeric> mtClose;Numeric refCurBar;Numeric refOpen;Numeric refHigh;Numeric refLow;Numeric refClose;Numeric refVol;Numeric refOpenInt;
Numeric SumValue(0);Numeric i;Numeric j(0);BeginmtBarCnt = MtBar(TimeFrame,BarsBack,refCurBar,refOpen,refHigh,refLow,refClose,refVol,refOpenInt);mtClose = refClose;
SumValue = MtSummation(mtClose,mtBarCnt,Length);oMA = SumValue/Length;Return mtBarCnt;End

The yellow line is the cross-cycle moving average. It is necessary to judge the major-level trend, and it is necessary to follow the trend during the day.

Strength judgment, obtain the change value of strength index across cycles

Gap filter

Although the overall center of gravity has moved down, intraday trading is not easy to do. This situation is common, but it is not good for statistical characteristics, so it is set to not do it for the time being.

Move out:

Oscillation filter:

performance test

TBquant platform (from 2019 to now, the platform limit is 5Wbar, please see WH8 for 10-year test):

Mandarin 8 Platform (2010-2021):

Summarize   

The model order is placed after the K line is completed. The closing price model is very versatile. The TB of SF34 is very close to the source code performance test of Wenhua platform. The intraday model of the stock index can continue to be optimized. In order to reduce the number of transactions in the volatile market, the conditions are set too strict, and some markets may be missed. It is recommended to use it as an auxiliary strategy in combination with trend strategies. If there are problems or ideas for improvement, let's communicate in the community.

This strategy is only used for learning and communication, and investors are personally responsible for the profit and loss of real trading.

Guess you like

Origin blog.csdn.net/m0_56236921/article/details/123634740