ADX GADIENT LEVEL

Created at 02 Feb 2022, 08:42
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
ST

steel.export

Joined 19.01.2021

ADX GADIENT LEVEL
02 Feb 2022, 08:42


In the below code the cBot starts executing trade when the ADX Gradient starts rising from below - level 1.  Can you please correct the code so that cBot Starts when the Gradient is rising upward and above the level of 25, and Stops when the Gradient is going downward.

Thanking you in Advance for your Help & Support.

 

  private bool CheckADX()
        {
            if (adxType == ADXType.None)
            {
                return true;
            }

            double adxLastLevel = adx.ADX.Last(1);
            double adxPreviousLevel = adx.ADX.Last(2);
            if (adxType == ADXType.Gradient)
            {
                if (adxLastLevel > adxPreviousLevel)
                {
                    return true;
                }
            }
            else
            {
                if (adxLastLevel > adxLevel)
                {
                    return true;
                }
            }
            return false;
        }


@steel.export
Replies

amusleh
03 Feb 2022, 08:45

Hi,

Do you mean something like this:

        private bool CheckADX()
        {
            if (adxType == ADXType.None)
            {
                return true;
            }

            double adxLastLevel = _adx.ADX.Last(1);
            double adxPreviousLevel = _adx.ADX.Last(2);

            if (adxType == ADXType.Gradient)
            {
                // it will return true if ADX is raising and it's above 25
                if (adxLastLevel > adxPreviousLevel && adxLastLevel > 25)
                {
                    return true;
                }
            }
            else
            {
                if (adxLastLevel > adxLevel)
                {
                    return true;
                }
            }

            return false;
        }

You can add more conditions on an if statement by using && (and) or || (or),


@amusleh

steel.export
03 Feb 2022, 10:27

RE: ADX GRADIENT LEVEL

amusleh said:

Hi,

Do you mean something like this:

        private bool CheckADX()
        {
            if (adxType == ADXType.None)
            {
                return true;
            }

            double adxLastLevel = _adx.ADX.Last(1);
            double adxPreviousLevel = _adx.ADX.Last(2);

            if (adxType == ADXType.Gradient)
            {
                // it will return true if ADX is raising and it's above 25
                if (adxLastLevel > adxPreviousLevel && adxLastLevel > 25)
                {
                    return true;
                }
            }
            else
            {
                if (adxLastLevel > adxLevel)
                {
                    return true;
                }
            }

            return false;
        }

You can add more conditions on an if statement by using && (and) or || (or),

Dear Mr. Ahmad Musleh,

Thanks a lot for your Help and Support. 

Can you please send your email or contact me on altaf.rehmatwala@gmail.com.  I tried to reach you on your gmail, but no reply.

Thanks & Best Regards,

Altaf

 


@steel.export