Topic: Questions About ambiguous Codes inside indicators '' Why & What

Sometimes i see some small parts inside codes and donot know why they are here and what they are doing  i will post my Questions here and i hope answers will help

1st Question: In Balance of Power Indicator

// Calculation
            int iFirstBar = iPeriod + 2;

            var adBop = new double[Bars];

            for (int iBar = 1; iBar < Bars; iBar++)
            {
                if (High[iBar] - Low[iBar] > Point)
                    adBop[iBar] = (Close[iBar] - Open[iBar])/(High[iBar] - Low[iBar]);
                else
                    adBop[iBar] = 0;
            }

            adBop = MovingAverage(iPeriod, 0, maMethod, adBop);

Why  if (High[iBar] - Low[iBar] > Point) exist and what is the function of it ?

Re: Questions About ambiguous Codes inside indicators '' Why & What

The function? To define a movement bigger of at least 1 point or 1/10 of a point, depending on digits. To answer existential questions turn to a decent search engine and find the author and the concept behind the indicator.

Re: Questions About ambiguous Codes inside indicators '' Why & What

The answer is simple here. If "High[iBar] - Low[iBar]" = 0, we'll receive Deviation by zero error.
Since we compare double numbers we cannot use 0 for comparison. That's why Point is used as a minimal value (instead of zero).
Otherwise the code should be

Sigma = Point;
if(Math.Abs((High[iBar] - Low[iBar])-0) > Sigma) ...

Most probably High[iBar] is always greater or equal to  Low[iBar]. That's why the code is simplified to

if (High[iBar] - Low[iBar] > Point)

Re: Questions About ambiguous Codes inside indicators '' Why & What

I'm posting description of some parameters:

IsDeafultGroupAll = true; /false;

Default value: IsDeafultGroupAll = false;

It sets if the program uses the default group for the indicator as per the corresponding slot or sets group "All".

Normally FSB sets the Logical Groups of the indicators automatically. It sets group "A" for the first "Opening Logic Slot", group "B" for the second...  The program sets group "a" for all "Closing logic slots" by default.

This logic works for most of the indicators, but some indicators require to be used in all groups. Some examples are "Entry Time", "Enter Once", "Long or Short"...

IsGeneratable = true; /false;

Default value:  IsGeneratable = true;
Sets if Generator will use this indicator.

We set IsGeneratable = false; for the indicators, we don't to be used in Generator. Examples are: Long or Short, Lot Limiter...

IsDiscreteValues = true; /false;

Default value: IsDiscreteValues = false;

Most of the indicators has moving values, but some of them has jumping values.
We set IsDiscreteValues = true; for the indicators that stay constant for several bars. For example: Aroon Histogram.

Re: Questions About ambiguous Codes inside indicators '' Why & What

Thanks footon And Pop now its clear to me

Re: Questions About ambiguous Codes inside indicators '' Why & What

Why

using System;

in indicator like moving average

and not using it in Donchian Channel For example

Re: Questions About ambiguous Codes inside indicators '' Why & What

System namespace contains many important .NET classes as Math, Enum, ...

In your question, MA uses Enum class to take the list of MAMethod items:


IndParam.ListParam[1].Caption = "Smoothing method";
IndParam.ListParam[1].ItemList = Enum.GetNames(typeof (MAMethod));
IndParam.ListParam[1].Index = (int) MAMethod.Simple;

Here

IndParam.ListParam[1].ItemList = Enum.GetNames(typeof (MAMethod));

can be replaced with the following one without System namespace:

IndParam.ListParam[1].ItemList = new string[] {"Simple", "Weighted", "Exponential", "Smoothed"};

However, the first code has a big advantage that if you add new Moving Average type in the future, it will be automatically added to the indicator. If you use the second code, you have to add the new method manually.
Other advantage is that you are protected from a spelling mistake. The following code will be compiled successfully, but the indicator will crash on runtime (Sample).

IndParam.ListParam[1].ItemList = new string[] {"Sample", "Weighted", "Exponential", "Smoothed"};