Question regarding MQL4 iStochastic and comparative cAlgo

Post Reply
User avatar
bodleytunes
Trader
Posts: 68
Joined: Tue Oct 02, 2012 8:38 am
Location: Stockport

Question regarding MQL4 iStochastic and comparative cAlgo

Post by bodleytunes »

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.
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Re: Question regarding MQL4 iStochastic and comparative cAlg

Post by milanese »

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
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
User avatar
bodleytunes
Trader
Posts: 68
Joined: Tue Oct 02, 2012 8:38 am
Location: Stockport

Re: Question regarding MQL4 iStochastic and comparative cAlg

Post by bodleytunes »

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
User avatar
bodleytunes
Trader
Posts: 68
Joined: Tue Oct 02, 2012 8:38 am
Location: Stockport

Re: Question regarding MQL4 iStochastic and comparative cAlg

Post by bodleytunes »

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;

        }
:)
Post Reply

Return to “Coders Hangout”