Tongdaxin automatic envelope index formula and ATR channel index

According to Alexander Elder's description in his book "Trading for a Living", the design idea of ​​​​the automatic envelope is to treat the channel as trying on shirts, looking for those shirts that are neither too loose nor too tight, only Leave your wrists and neck exposed. The automatic envelope adapts to recent market fluctuations, and only in extreme cases, the price will go outside the range of the channel.

The book uses the 13-day EMA moving average and the 26-day EMA moving average, and the channel is parallel to the 26-day EMA moving average.

Upper channel=EMA26+channel coefficient*EMA26

Lower channel=EMA26-channel coefficient*EMA26

The channel coefficient needs to be adjusted continuously until the channel line can completely contain 95% of the price data of the last 100 K lines.

The calculation of the channel coefficient is more brain-intensive, but Technical Pie still came up with a method that feels good. Assuming that the channel already exists, 95 of the last 100 K lines have been enclosed in the channel, and 5 have not been enclosed. These 5 K lines are the farthest from the EMA26 daily moving average (the degree of deviation before 5 names, 12345 in the picture below). If we find the K-line that deviates from the 6th EMA26 daily moving average and calculate its deviation value, we can determine the channel coefficient. Because as long as the 6th farthest K line is wrapped, the remaining 94 lines will be included in the channel.

1. Automatic envelope index formula

EMA13:=EMA(CLOSE,13);

EMA26:=EMA(CLOSE,26);

PL:=MAX(H-EMA26,EMA26-L);{Calculate the degree of deviation from the EMA26 moving average}

P6:=CONST(FINDHIGH(PL,0,99,6));{The degree of deviation of the last 100 K lines that deviate from the 6th farthest}

N:=P6/EMA26;{calculate channel coefficient}

UP:EMA26+N*EMA26,DOTLINE,COLORYELLOW;{up channel, yellow dotted line}

DN:EMA26-N*EMA26,DOTLINE,COLORYELLOW;{lower channel, yellow dotted line}

{The following is the power system index formula}

DIF:=EMA(C,12)-EMA(C,26);

DEA:=EMA(DIF,9);

MACD:=(DIF-DEA)*2;

RBAR:=EMA13>REF(EMA13,1) AND MACD>REF(MACD,1);

CBAR:=EMA13<REF(EMA13,1) AND MACD<REF(MACD,1);

GBAR:=IF(RBAR OR CBAR,0,1);

STICKLINE(RBAR,H,L,0,1),COLORRED;

STICKLINE(RBAR,C,O,3,1),COLORRED;

STICKLINE(CBAR,H,L,0,0),COLORCYAN;

STICKLINE(CBAR,C,O,3,0),COLORCYAN;

STICKLINE(GBAR,H,L,0,0),COLORLIGRAY;

STICKLINE(GBAR,C,O,3,0),COLORLIGRAY;

EMA13,COLORWHITE;

EMA26,COLORYELLOW;

 

 

The formula needs to pay attention to two points:

1. In order to realize the automatic adjustment of the channel, P6:=CONST(FINDHIGH(PL,0,99,6)); This sentence uses the CONST function, which will correct the channel according to the latest market price, and the displayed channel is not suitable for the historical market. If you want to view the historical situation, you can use the "training mode" or "sand table deduction" for review. In addition, if you want to directly view the historical situation, you can remove the CONST function, P6:=FINDHIGH(PL,0,99,6);, so that the channel of the historical market will not change, and there will be no automatic envelope effect purely from the graph up.

2. The power system part in the formula has been introduced in detail in the previous article, and will not be repeated here.

2. ATR channel indicator formula

Alexander Elder's friend Kerry Lovorn uses the ATR channel, and the three sets of channel lines are set at 1, 2, and 3 times the ATR from the 21-day EMA moving average. Normal fluctuations are often within the channel of 1 times ATR, and extreme market conditions will break out of the channel of 3 times ATR.

ATR is the average true volatility, first calculate the real volatility, take "the volatility of the highest price and the lowest price of the day", "the volatility of yesterday's closing price and today's highest price", "the volatility of yesterday's closing price and today's lowest price" The maximum value, and then calculate the 14-day moving average of the maximum value to get the ATR.

MTR:=MAX(MAX((H-L),ABS(REF(C,1)-H)),ABS(REF(C,1)-L));

ATR:=MA(MTR,14);

EMA21:EMA(C,21),COLORWHITE;

UP1:EMA21+ATR,COLORYELLOW;{1 times ATR upper channel}

UP2:EMA21+ATR*2,DOTLINE,COLORMAGENTA;{2 times ATR upper channel}

UP3:EMA21+ATR*3, COLORLIGRAY; {3 times ATR upper channel}

DN1:EMA21-ATR,COLORYELLOW;{1 times ATR lower channel}

DN2:EMA21-ATR*2,DOTLINE,COLORMAGENTA;{2 times ATR down channel}

DN3:EMA21-ATR*3,COLORLIGRAY;{3 times ATR lower channel};

 

Pay attention to Technical Pie and learn more knowledge about writing Tongdaxin indicator formulas. All rights reserved, please indicate the source.

Friendly reminder: This article is only for learning and exchanging technical indicator formulas, and does not constitute any investment advice. Investment is risky, and you need to be cautious when entering the market.

Guess you like

Origin blog.csdn.net/m0_74754828/article/details/131088685