nastrojki-indikatora-macd.png 💥The Moving Average Convergence Divergence (MACD) is a technical analysis indicator that helps traders identify potential buying and selling signals. It is based on the difference between two exponential moving averages (EMAs) of different periods, typically 12 and 26 days. 💥The MACD has a signal line, which is typically a 9-day EMA of the MACD line. When the MACD line crosses above the signal line, it is considered a bullish signal, indicating a potential buying opportunity. Conversely, when the MACD line crosses below the signal line, it is considered a bearish signal, indicating a potential selling opportunity. 💥Another way to use the MACD is to look for support and resistance levels. When the MACD line crosses above the zero line, it indicates that the short-term moving average is above the long-term moving average, which can be seen as a bullish signal. The zero line can also act as a support level, as prices may find it difficult to break below this level. Conversely, when the MACD line crosses below the zero line, it indicates that the short-term moving average is below the long-term moving average, which can be seen as a bearish signal. The zero line can also act as a resistance level, as prices may find it difficult to break above this level. 💥In fact, the MACD is another type of indicator that should be categorized as such. However, due to its close relationship with the moving average system, it is brought together in this chapter. 💥As mentioned earlier, the system uses two moving averages, which usually give a slower signal, but because the average movement is smoother, it makes it possible to filter false signals well with less error. Gerald Appel tried to find a system that would play a good part in filtering false signals while giving a faster signal than the two moving averages, which eventually became the source of the MACD. 💥Appel noted that in the two moving average system, before the two mean lines close to intersect (that is, before it sends a buy or sell signal), the two lines will run closer together until they finally intersect. As the two lines approach each other, the distance between them shrinks by default. Therefore, he proposed to plot the distance between the two moving averages as the MACD line when the moving averages cross. When the short moving average line crosses the long moving average upward (Buy Signal in a two-line average system), the MACD crosses the 0 line upward, and when the short moving average line crosses the long moving line downward (Sell Signal), the MACD crosses the 0 line down. 💥Appel proposes using the 12-day EMA (smoothing constant = 0.15) as the short-term average and the 26-day EMA (smoothing constant = 0.075) as the long-term average. MACDpicwiki.gif MACD = EMA(12)-EMA(26) 💥The MACD can be expressed by the formula EMA(12)-EMA(26). This MACD is a special case of the previously mentioned price oscillator. By plotting the MACD line, traders can see that it changes trend in certain situations. For example, sometimes the price is still rising but the distance between the two moving averages has decreased, causing the MACD to trend downward. This creates a divergence between the price and the MACD, indicating a potential change in direction. 💥Traders can also use the principle of moving average to generate trading signals based on the MACD. Appel suggests using the dotted line of the 9-day MACD with a smoothing constant of 0.2 as a signal. When the MACD crosses its 9-day EMA upward, it is a buy signal. Conversely, when the MACD crosses the 9-day EMA downward, it is a sell signal. 💥Therefore, the MACD provides two levels of trading signals. The first level is a fast signal level based on the intersection of the MACD line with its 9-day moving average. The second level is a slower but more reliable signal: when the MACD crosses the 0 line, just like the two moving average lines in the system. 💥The zero line can also be used as a support or resistance level. If the 10-day EMA does not fall through the zero line, it can bounce up and act as a support level, indicating that a sell signal may not occur. If there is buying pressure or another support, some traders use it as an opportunity to buy stocks again. However, if the MACD falls through the zero line, it becomes a resistance level.
Creating a strategy in the Designer program. Let’s discuss an example of creating a trading strategy in a program based on the MACD indicator values. The indicator’s goal is as follows: 1. If the MACD indicator histogram crosses the zero line from top to bottom, this is a sell signal. 2. The transition of the histogram from the negative to the positive zone is a buy signal. Therefore, it is necessary to create conditions under which a trade will be made, namely, if the indicator value on the next candle changes its sign, then the signal is sent to make a trade. To create a strategy, we need: - Run the program. 1.png - Select the Variable, Candles and Chart Panel blocks, connect them. 2.png - Select an instrument with which we will test the strategy. 3.png - Plot a candle chart. 4.png - Select the Indicator and Chart Panel blocks. Connect the Indicator and Candles blocks. 5.png - Plot a chart of the MACD indicator. 6.png - Select the Variable block and assign it a numeric value of 0 for further comparison with the indicator value. 7.png - Select the Comparison block and set the test condition in the properties: execution during the test, with the MACD indicator value greater than 0. - Add two Variable blocks and Comparison block. One of the variables is set to -1 in the block properties. It will indicate the transition of the MACD curve value from negative to positive area. The second Variable value is set to 0 in the properties, that will indicate the initial indicator value. - Set the condition in the Comparison block that will be fulfilled if the initial indicator value for the time frame is greater than the current one. - Connect the Variable blocks via a trigger socket with the Comparison blocks, as shown in the figure. Select the Logical Condition and Variable cubes. 8.png - The execution condition of two comparisons will be checked in the Logical Condition cube. Set the AND condition in the properties of the Logical Condition cube and connect the cubes as shown in the figure. 9.png - Set the value equal to -1 in the Variable cube and connect it with the Logical Condition cube via a trigger socket, and through the output connect to the input of the cube with a value of 0. This will allow overwriting the checkbox value when conditions are met, indicating within what range of values the MACD indicator curve is. 10.png - Select the Open Position block, select the Buy direction in the settings and connect data and trigger with the socket, as shown in the figure. 11.png - Select two Variable blocks in which to set the volume and portfolio for trading. Connect them with the corresponding sockets of the Open Position block. 12.png - Similarly, create a routine for the Sales execution. 13.png -The strategy is ready, let’s run it. 14.png