SF16 | "Bump" moving average pattern trading strategy source code (technical post)

 Committed to sharing quantitative strategies, training videos, Python, algorithm research and other related content.

What is the convex and concave shape? It refers to the bending direction and bending degree of the moving average. It can be divided into three forms, namely upward convex (downward concave), downward convex (upward concave), and straight line. How do investors understand this trend? We will use the usual iron pot to illustrate. When an iron pot is upside down, it is called convex (concave down); if the iron pot is placed squarely, it is called Convex downward (concave upward), and straight line, refers to when there is no curvature.

The appearance of an iron pan upside down is called convex (concave).

The appearance of an iron pot being placed upside down is called downward convex (upward concave).

When the price rises, the moving average is in a downward convex (upward concave) shape, which is the most ideal starting point, and all the moving averages at the starting point are in this shape. If the price rises and rises, it is in a convex (concave) pattern, which is the most unsatisfactory rising state. If it is a straight line, it needs to be topped according to the angle. Of course, neither of them is the form of the take-off point. Therefore, we need to look for varieties with a large downward convex (upwardly concave) angle when the moving average rises. The bigger the better, it will fly very high, and vice versa.

Compared with the algorithm strategy, the shape strategy is difficult to form a unified description and calculation method. Many subjectively think that a good shape is difficult to accurately describe in quantification. The SF16 strategy defines the complex "concave-convex" moving average pattern, and then further optimizes and corrects it to make it a complete trading strategy.   

The core algorithm principle of concave-convex moving average

Core calculation formula:

First, two moving averages, long and short, are needed to determine the intersection. The Linear (rate of change) of the intersection is saved as the star_N value, and then the iterative calculation of min_L is started to save the minimum Linear value; when the latest Linear value is greater than the minimum value and greater than star_N* When the value of (1+X) is used, it can be determined that a concave shape has appeared, as shown in the following figure:

The above is a calculation example for long (concave), and vice versa for short;

Next, let's take a look at the performance of different platforms in SF16, using Trading Trailblazer (TB) as the demonstration platform:

Applicable period: 15 minutes and above;

Handling fee: 1.5%%, 1 hop in each direction;

Test time: 2008 to present

Default lot size: 1 lot

Tested varieties: thread, coke, thermal coal, crude oil, apple, PTA, PP, iron ore

Comprehensive test:

Thread:

Coke:

iron ore:

Thermal coal:

crude:

apple:

PER:

PP:

Mandarin (WH8):

MC:

pyramid:

Note: Because the mechanism of opening and closing positions is different, MC Pyramid and Wenhua both open positions after the K line, while TB’s open positions in the native code BAR, so the performance will be different;

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/123223134