1 (edited by Peter83 2011-12-23 18:08:11)

Topic: Definition of 'rising'

Hello,

what does the term rising in the description of the opening logic of some indicators exactly mean?

I'm trying to verify the backtesting results of FSB by backtesting with the same data converted as fxt-files (and therefore tick data) with the mt4 backtester.

I backtested the following simple strategy:

entry: bar opening + macd histogram (exponential, close, simple, 26, 12, 9) rising
exit: with bar closing + macd histogram falling

Now I try to implement this with MQL Editor and defined rising/falling as a positive/negative difference to the last MACD histogram value.
example mql4 code:
last_macd=iMACD(Symbol(), 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1);

The results differ very much from the results in FSB concerning entry and exits of the trades. So I need to know how you define rising and falling.

Thanks.

Re: Definition of 'rising'

protected bool OscillatorLogic(int iFirstBar, int iPrvs, double[] adIndValue, double dLevelLong, double dLevelShort, ref IndicatorComp indCompLong, ref IndicatorComp indCompShort, IndicatorLogic indLogic)
        {
            double dSigma = Sigma();
 
            switch (indLogic)
            {
                case IndicatorLogic.The_indicator_rises:
                    for (int iBar = iFirstBar; iBar < Bars; iBar++)
                    {
                        int  iCurrBar  = iBar - iPrvs;
                        int  iBaseBar  = iCurrBar - 1;
                        bool bIsHigher = adIndValue[iCurrBar] > adIndValue[iBaseBar];
 
                        if (!isDescreteValues)  // Aroon oscillator uses bIsDescreteValues = true
                        {
                            bool bNoChange = true;
                            while (Math.Abs(adIndValue[iCurrBar] - adIndValue[iBaseBar]) < dSigma && bNoChange && iBaseBar > iFirstBar)
                            {
                                bNoChange = (bIsHigher == (adIndValue[iBaseBar + 1] > adIndValue[iBaseBar]));
                                iBaseBar--;
                            }
                        }
 
                        indCompLong.Value[iBar]  = adIndValue[iBaseBar] < adIndValue[iCurrBar] - dSigma ? 1 : 0;
                        indCompShort.Value[iBar] = adIndValue[iBaseBar] > adIndValue[iCurrBar] + dSigma ? 1 : 0;
                    }
                    break;
 
                case IndicatorLogic.The_indicator_falls:
                    for (int iBar = iFirstBar; iBar < Bars; iBar++)
                    {
                        int  iCurrBar  = iBar - iPrvs;
                        int  iBaseBar  = iCurrBar - 1;
                        bool bIsHigher = adIndValue[iCurrBar] > adIndValue[iBaseBar];
 
                        if (!isDescreteValues)  // Aroon oscillator uses bIsDescreteValues = true
                        {
                            bool bNoChange = true;
                            while (Math.Abs(adIndValue[iCurrBar] - adIndValue[iBaseBar]) < dSigma && bNoChange && iBaseBar > iFirstBar)
                            {
                                bNoChange = (bIsHigher == (adIndValue[iBaseBar + 1] > adIndValue[iBaseBar]));
                                iBaseBar--;
                            }
                        }
 
                        indCompLong.Value[iBar]  = adIndValue[iBaseBar] > adIndValue[iCurrBar] + dSigma ? 1 : 0;
                        indCompShort.Value[iBar] = adIndValue[iBaseBar] < adIndValue[iCurrBar] - dSigma ? 1 : 0;
                    }
                    break;

I've experienced that FSB's MACD and MT's MACD are not matching indis, before you made your test did you make sure you were comparing apples to apples?