stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Question regarding MQL4 iStochastic and comparative cAlgo
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3290
Page 1 of 1
Author:  bodleytunes [ Wed Nov 27, 2013 12:57 pm ]
Post subject:  Question regarding MQL4 iStochastic and comparative cAlgo

Hi peeps,

I'm trying to see if there is an equivalent calgo parameter to "MODE_SIGNAL" and "MODE_MAIN" which are resident in the MQL4 language.

I'm looking at an mql4 snippet of code and the iStochastic interface seems to have more parameters than the "Indicators.StochasticOscillator" that there is in cAlgo .

I cannot see an equivalent param as MODE_SIGNAL and MODE_MAIN and to set these I assume would return differing values as the MQL I'm looking at has an

Code: Select all

if .... istochastic (x , MODE_MAIN)  <  istochastic (x , MODE_SIGNAL)
where all the arguments designated as X are exactly the same on each side, the only difference in the mode_signal vs mode_main

Just wondering how I could reproduce this in cAlgo, I'm sure its pretty easy but I'm a newbie when it comes to getting my simple mind around this stuff.

Cheers! :)

Jon.
Author:  milanese [ Wed Nov 27, 2013 1:02 pm ]
Post subject:  Re: Question regarding MQL4 iStochastic and comparative cAlg

bodleytunes wrote:Hi peeps,

I'm trying to see if there is an equivalent calgo parameter to "MODE_SIGNAL" and "MODE_MAIN" which are resident in the MQL4 language.

I'm looking at an mql4 snippet of code and the iStochastic interface seems to have more parameters than the "Indicators.StochasticOscillator" that there is in cAlgo .

I cannot see an equivalent param as MODE_SIGNAL and MODE_MAIN and to set these I assume would return differing values as the MQL I'm looking at has an

Code: Select all

if .... istochastic (x , MODE_MAIN)  <  istochastic (x , MODE_SIGNAL)
where all the arguments designated as X are exactly the same on each side, the only difference in the mode_signal vs mode_main

Just wondering how I could reproduce this in cAlgo, I'm sure its pretty easy but I'm a newbie when it comes to getting my simple mind around this stuff.

Cheers! :)

Jon.

Hi Jon ,

you may take a look at this http://ctdn.com/algos/indicators/show/167

Cheers :)

Tommaso
Author:  bodleytunes [ Wed Nov 27, 2013 1:20 pm ]
Post subject:  Re: Question regarding MQL4 iStochastic and comparative cAlg

milanese wrote:
bodleytunes wrote:Hi peeps,

I'm trying to see if there is an equivalent calgo parameter to "MODE_SIGNAL" and "MODE_MAIN" which are resident in the MQL4 language.

I'm looking at an mql4 snippet of code and the iStochastic interface seems to have more parameters than the "Indicators.StochasticOscillator" that there is in cAlgo .

I cannot see an equivalent param as MODE_SIGNAL and MODE_MAIN and to set these I assume would return differing values as the MQL I'm looking at has an

Code: Select all

if .... istochastic (x , MODE_MAIN)  <  istochastic (x , MODE_SIGNAL)
where all the arguments designated as X are exactly the same on each side, the only difference in the mode_signal vs mode_main

Just wondering how I could reproduce this in cAlgo, I'm sure its pretty easy but I'm a newbie when it comes to getting my simple mind around this stuff.

Cheers! :)

Jon.

Hi Jon ,

you may take a look at this http://ctdn.com/algos/indicators/show/167

Cheers :)

Tommaso
Thanks Tommaso, I will give it a read :D
Author:  bodleytunes [ Wed Nov 27, 2013 3:59 pm ]
Post subject:  Re: Question regarding MQL4 iStochastic and comparative cAlg

I'm flummoxed, as that custom stoch inidicator doesn't seem to make reference to the "Main" output.

Only the "signal" output is referenced in the "Calculate" void method?

Am I supposed to customise this even more and create the main output, possibly creating my own function which returns a value rather than just paints a line?

Code: Select all

 [Output("Main", Color = Colors.Blue)]
        public IndicatorDataSeries Result { get; set; }

Code: Select all

public override void Calculate(int index)
        {
            if (index < FastK)
            {
                Result[index] = 0;
                Signal[index] = 0;
                return;
            }

            double min = MarketSeries.Low.Minimum(FastK);
            double max = MarketSeries.High.Maximum(FastK);
            double fast = 0.0;

            if (Math.Abs(max - min) > double.Epsilon)
                fast = (MarketSeries.Close[index] - min) / (max - min) * 100;

            Result[index] = Result[index - 1] + (fast - Result[index - 1]) / SlowK;
            Signal[index] = Signal[index - 1] + (Result[index] - Signal[index - 1]) / SlowD;

        }
:)
All times are UTC Page 1 of 1