Topic: Moving Average Logic

Can someone please clarify the opening logic with the Moving Average. What I am looking for is a bar that opens below the moving average and closes above it. Then I want to enter long on the next bar. So basically I will open at the open of the next bar.

One of the logic settings in Moving Average is "The bar opens below the moving average after opening above it" which is really a contradiction.

What exactly does this logic mean because it can't open below and above at the same time, can it?

Re: Moving Average Logic

It is previous bar opens below, current bar opens above and vice versa. Opening of the position is carried out at the beginning of the current bar, it is when we know it has opened above/below the MA. Study the charts, maybe you'll find that it does what you need after all.

Re: Moving Average Logic

Footon , but using this condition means we override the previous bar option am i right!!!!

Re: Moving Average Logic

ahmedalhoseny wrote:

Footon , but using this condition means we override the previous bar option am i right!!!!

What do you mean by it? Previous bar value usage? If you mean PBV, then it doesn't override, look at the logic calculation block:

protected void BarOpensAboveIndicatorAfterOpeningBelowLogic(int iFirstBar, int iPrvs, double[] adIndValue, ref IndicatorComp indCompLong, ref IndicatorComp indCompShort)
        {
            double dSigma = Sigma();
 
            for (int iBar = iFirstBar; iBar < Bars; iBar++)
            {
                int iBaseBar = iBar - 1;
                while (Math.Abs(Open[iBaseBar] - adIndValue[iBaseBar - iPrvs]) < dSigma && iBaseBar > iFirstBar)
                { iBaseBar--; }
 
                indCompLong.Value[iBar]  = Open[iBar] > adIndValue[iBar - iPrvs] + dSigma && Open[iBaseBar] < adIndValue[iBaseBar - iPrvs] - dSigma ? 1 : 0;
                indCompShort.Value[iBar] = Open[iBar] < adIndValue[iBar - iPrvs] - dSigma && Open[iBaseBar] > adIndValue[iBaseBar - iPrvs] + dSigma ? 1 : 0;
            }
 
            return;
        }

First open from current bar compared to previous bar MA, then previous open compared to MA value from the second bar from current.