4.1 The reproduction of the quantitative paper "Automatic one two three"

think

1. Why write a quantitative blog?

According to my personal understanding, the ideas of quantification can be divided into several types, factor model asset portfolio, high-frequency trading arbitrage, and technical analysis.
Because my knowledge reserve and professional level are limited, I initially plan to start with technical analysis and learn gradually. And share the learning content to the Internet to fight against your own procrastination.

2. Why start with technical analysis first?

Whether technical analysis is effective has not been verified, but I have a little understanding of some points of view: for example, human beings like to follow hot spots, excessive borrowing and consumption should lead to trends and economic cycles. If my understanding is correct, then there must be a way to capture trends and cycles through technical analysis.

3. Why do you want to reproduce this paper

The direction I found from this article [Dry goods] Quantitative Finance magazine’s top ten articles in the field of quantitative trading
Because this article is in English, it is difficult to read, but I really want to understand the content. I can’t stick to it after translating every sentence and reading halfway through. After two or three weeks, there is no progress, so I will summarize and give feedback in the form of blogging.
There are still many tool elements in this article that are worth learning, such as signal filtering and other content. I hope that by learning the methods, I can understand and apply them to actual combat. Actual combat is the ultimate goal.

4. Next step plan

I initially plan to reproduce this article first, because there is a lot I don’t understand at the beginning, please leave a message if you are lucky enough to read this article, know more, and give me some learning guidelines, please.

Without further ado, let's get started.

Full text reading and understanding

《Automatic one two three》 ,Stanislaus Maier-Paape

In this article, we show how to automatically calculate the market technical trend from the underlying price process using the stop and reverse process. The most basic tool is a so-called min-max procedure that displays all relevant min and max values. We give a constructive proof for the existence of minmax processes. Several successful trend-following trading strategies can be automated based on this 1-2-3 trend indicator.

1、设计工具minmax process
2、通过工具minmax process 、与ohlc数据,生产出123指标数据
3、通过123指标实施几种交易策略

1. Introduction

Back to Charles H. Dow,trendthe concept ofis the core of trading financial markets(cf. Russell 1981). We use (Market Technology)A trend is defined as follows:

Definition 1.1 (Definition)

(Market Technical Trends) A financial market is in an uptrend if the most recent (at least two) consecutive relative lows and highs have been rising. To be precise, we assume that all lows are monotonically increasing, and even highs are strictly monotonically increasing. Similarly, a downtrend occurs when the last relevant low and high are both declining (lows are even strictly monotonically decreasing). If there is neither an uptrend nor a downtrend, the market is said to be trendless.

趋势:最近至少两个高点上升 and 最近至少两个低点上升
反之无趋势

Remark 1.2 (Remarks)

The above definition allows the lows in an uptrend to be at the same level, while each new high in an uptrend must be strictly higher than the previous one. If in an active uptrend, the next high is at the same level as (or even lower than) the previous one, it is usually a bearish sign. We refer to this situation as a "problematic trend" (see Section 3 Definition 3.1 for details)

1、低点可以水平,高点必须更高
2、上升中出现高点处于同一水平(甚至更低)→“有问题的趋势”→看跌

Definition 1.3

In an uptrend, the phase between a minimum and the next (higher) maximum is called a move, while the phase between a maximum and the next (higher) minimum is called a correction. In a downtrend, moves and corrections are defined similarly (mirrored).

movement:同大趋势方向
correction:逆大趋势方向

While this definition is intuitive at first glance, it is problematic in two ways.
First, the concept of high and low is subjective to the observer. For some observers, only large extrema are relevant, while others consider small extrema to be relevant. This sensitivity problem is not limited to humans. Even a mathematically precise definition cannot solve this problem, as shown in Figure 2.
The continuation process dents a new minimum in the left graph until the minimum is clearly identifiable as a correlated minimum next to two correlated maxima (right graph). Since the process is continuous, the decision from when this new minimum is relevant must be subjective.
Another problem with defining relative extrema is the time scale. Clearly, there are more extreme case charts on the 10-minute histogram than on the daily or even weekly histogram. Therefore, our position is that the answer to the question whether the market is trending or not depends on the time scale we are looking at.
For example, a market may be correcting against an apparent uptrend on a daily basis, while at the same time, the market is undergoing an hourly downtrend (see Figure 3). For further reference, we present the numbering of relevant extrema in trends, e.g. Voigt (2008).

存在两个问题:
1、主观转化为量化、凹形形态无法避免主观性
2、时间尺度,固定时间尺度

Definition 1.4

(1-2-3-trend number) In an uptrend, the initial minimum is marked with a 1, the subsequent maximum with a 2, and the next (higher) minimum with a 3. Larger maximums (minimums) are also numbered with 2 (3) (see Figure 1).
Same numbers, but mirrored, for downtrends (cf. Fig. 3). In sequels, we usually refer to points 2 or 3, which are at these extreme price levels.

标记方法:1 23 23 23 23 23

2.8 minmax basic strategy

Basic MinMax Strategy 2.8.
Whenever Status[0] = +1,
we search for a relevant maximum, and
whenever Status[0] = −1,
we search for a relevant minimum.
At this point we still have to discuss how the exceptional
situations may end. Assuming again the situation of figure 11,
there are two possibilities:
(i) The prices continue to fall and eventually the direction
changes to −1.
(ii) Thepricesstartrisingagainandexceedeventuallyabove
the last relevant maximum that had to be fixed on entry
of the exceptional situation.
In both cases, we switch back to normal, i.e. in case (i)
we just change Excep[0] back to 1 (yielding Status[0] =
−1) and in case (ii) we change Excep[0] back to 1 (yield-
ing Status[0] = 1) and additionally fix the recently found
minimum, i.e. we continue to search for a new maximum.
For definiteness, we give the update of the Excep series
once the last relevant maximum (at absolute period number
lastmaxbar) and the last relevant minimum (at absolute
period number lastminbar) have been found:

Definition 2.9 Update Excep sequence

Definition 2.9 (Update Excep series)

If Excep[1] = −1 then
// exceptional process was already active
Excep[0] :=1 , in case Direction[1] · Direction[0] = − 1 
						or Direction[1] = 1 and High lastmaxbar≤ High[0] 
						or Direction[1] = −1 and Low lastminbar ≥ Low[0],
				  −1 , otherwise

else if Direction[1] = Direction[0] then
// check for exceptional situation
Excep[0] :=−1 , in case Direction[0] = 1 and Low lastminbar ≥ Low[0] 
										or Direction[0] = −1 and High lastmaxbar ≤ High[0]
					1,otherwise

In the following we use the convention that in case
Status[0] = 1, the last fixed relevant minimum
occurred in the period lastminbar
and the temporary maximum
afterwards is in the period tempmaxbar.
Similarly, in case
Status[0] = −1, the last fixed relevant maximum
occurred in the period lastmaxbar
and the temporary minimum afterwards
is in the period tempminbar.
Hence
lastminbar ≤ tempmaxbar and lastmaxbar
≤ tempminbar (if $Choice = 0)
or lastminbar < tempmaxbar and lastmaxbar
< tempminbar (if $Choice = 1)
are all absolute period numbers. Depending on whether we
allow minima and maxima to occur in the same period, we
get different processes of minima and maxima. This will be
modelled with the parameter $Choice. We will see later that
only $Choice = 0 yields a minmax process satisfying all
criteria of Definition 2.6.
In order that Definition 2.9 is well defined, we need to know
what lastmaxbar and lastminbar is. These two bars can
only be defined after the SAR process has finished initializing
(say Direction = 0 while initializing).

Definition 2.10 (initialization of max-min process)

Original:
Definition 2.10 (Initial MinMax process)

	If Direction[1] = 0 and Direction[0] = 1 then 
		lastminbar := period of lowest low of all	periods loaded so far.
	If Direction[1] = 0 and Direction[0] = −1 then
		lastmaxbar := period of highest high of all periods loaded so far.

In both cases, we start with Status[0] = Direction[0], i.e. Excep[0] = 1.
Having fixed, e.g. the last minimum at lastminbar, tempmaxbar is the period of the highest high after lastminbar as long as Status[0] = 1.

We therefore can now state how we update the minmax process.

Translation:
direction from 0→+1/-1, fixed max and min values

  • How to fix the sequence #2 question
    In these two cases, we start from Status[0] = Direction[0], that is, Excep[0] = 1. By fixing, for example, the
    last minimum value of lastminbar, as long as Status[0]= 1,
    tempmaxbar is the highest value after lastminbar.
    Therefore, we can now show how to update the minimax procedure.

Definition 2.11 (updating of the min-max process)

Definition 2.11 (Update MinMax process)
pseudocode

// Definition 2.11 (Update MinMax process)
If Status[1] = 1 then
	begin
		if High(tempmaxbar) ≤ High[0] then
			//update tempmaxbar
			tempmaxbar := CurrentBarIndex()
		if Status[0] = −1 then
			//Status has changed; fix the last maximum
			begin
				lastmaxbar := tempmaxbar
				tempminbar := bar of lowest low with lastmaxbar + α ≤ tempminbar ≤ 
				CurrentBarIndex(),
	where
		α :=
			1, if($Choice = 1) or(lastmaxbar = lastminbar)
			0, otherwise
			end
	end
if  Status[1] = −1 then
	begin
	if Low(tempminbar) ≥ Low[0] then
	//update tempminbar
		tempminbar := CurrentBarIndex()
	if Status[0] = 1 then
	//Status has changed; fix the last minimum
		begin
			lastminbar := tempminbar
			tempmaxbar := bar of highest high with
			lastminbar + α ≤ tempmaxbar
			≤ CurrentBarIndex()(24)
		//where α is defined as in (23)
		end
	end

Guess you like

Origin blog.csdn.net/weixin_42829932/article/details/128372424