XAverage from TS to MT4

 
Dear friends,

I started translating some TS indicators/signals/functions to MT4 and i need some advice, how can i manage the numeric series on MT4?

For example how could be the XAverage TS function translated to MT4?

Thanks for any help.

Regards
Alejandro Galindo
 
Hi Alejandro,

I don't know what XAverage TS is doing.

Numeric Series can simple be defined as double[] value; or int[] value;. Arrays defined like this can also be passed to a function.

With regards, cori
 
Thanks Cori,

Another thing i cant make to work is when the script (function) calls to itself (for a recursive algorithm).

Is there a way to have recursivity on MQ4 ?

Thanks
Alejandro Galindo
 
By the way, tis is the function iam trying to translate (the function name is XAverage so it calls to itself):

{*******************************************************************
Description: Exponential Average
Provided By: Omega Research, Inc. (c) Copyright 1999
********************************************************************}

Inputs: Price(NumericSeries), Length(NumericSimple);
Variables: Factor(0);

If Length + 1 <> 0 Then Begin
If CurrentBar <= 1 Then Begin
Factor = 2 / (Length + 1);
XAverage = Price;
End
Else
XAverage = Factor * Price + (1 - Factor) * XAverage[1];
End;
 
For recursion you should do something like this sample:

/* ****************************************************************** */
/* Copyright and pricing                                              */
/*                                                                    */
/* This code was developed by coriFX 2005.                            */
/*                                                                    */
/* You can use this code to make money as much as you wish without    */
/* fee. If you have made your first million using my code, I would    */
/* ask you to send me 10%. contact me at { corifx at o2go dot de }.   */
/* I will send you the information for money transfer.                */
/*                                                                    */
/* ****************************************************************** */
extern int maxLoops = 100;

int start() {


    Print( "recursiveFunction sample. Start recursion" );
    recursiveFunction( 0 );
    Print( "recursiveFunction sample. Ended" );

    return( 0 );
}


// Implementation of XAverage. Doing it with recursion
// shift- is necessary for recursion
void recursiveFunction( int shift ) {

    Print( "recursiveFunction called. shift: ", shift );
    if  ( shift < maxLoops ) {
        recursiveFunction( shift + 1 );
    }         
}



Post the result, if you have it running.

have luck, cori

 
I have forgotten: this is a script

cori
 
Thanks Cori,

I apreciate you help.

Regards
Alejandro Galindo