Description of the indicator.
This indicator was discussed at length in a previous publication. In this case, we call it «Multi Standard Dev Channel Color» because we simply added two other linear regression channels to improve the overview of prices for different time frames and, similarly, added color to the spaces between the channels. Remember that this indicator was introduced by Gilbert Raff and is based on the statistical principle of linear regression to project prices forward.
It was said that the linear regression channel indicator assumed an erroneous theory about price, namely that it follows a normal or Gaussian probability distribution. This is a conceptual error if time series are considered in the strict sense. However, since financial time series, being inherently social, have unique qualities that make them fundamentally different from those resulting from other disciplines, absolute precision is not always sought. Only then, conceptually, can these channels be as useful as traditional trend lines, but the user must be cautious when considering their limitations.
Explanation of the code.
Block 5-14: As with the «Standard Dev Channel Color» indicator, in this part of the code we define all the system input variables, except that we replicate each block three times so that we can configure the parameters separately instead of linking them to a single configuration, which could be counterproductive.
Block 16-42: In this section of the code, we define a pair of relative variables so that we can choose whether to plot the indicator using only a certain number of bars or all the visible data in the chart. Similarly, we replicate the block so that each channel has its own independent configuration.
Block 44-52: These instructions request the execution engine to display all previously defined elements on the current screen, i.e., the three linear regression channels, for specific bars and for a specific standard deviation. As can be seen, it is simply a matter of multiplying the linear regression line by the positive and negative standard deviations to draw the channel.
Block 54-75: Similarly, we use a block of code for each linear regression channel, as each one is independent of the rest; each one will have its own style and color; and each one will be drawn independently of the rest. The reason for this is not to complicate the code, but to make it easier for the user to configure it simply. Remember that these indicators are designed to perform a visual analysis of the charts. Code optimization is crucial when programming complete strategies, where it is not only important but necessary.
Block 77-82: Finally, we add six alerts with the Alert function, two for each channel, that is, for each channel crossing, whose parameters are: the logical activation condition, the message that will be displayed when activated, the associated alert location, and an associated sound.