Download MetaTrader 5
To add comments, please log in or register
Deposit to your account via Visa QIWI Wallet
Gordon Gekko
647
Gordon Gekko 2015.10.14 15:19 

Hi Gurus,

I can get iMaOnArray from an array, like this:

double Value=iMAOnArray(My_Array,0,Ma_Period,0,Ma_Method,0);


My question: is it possible to get iMaOnArray from an element of a structure?

Let's say I have this structure:

//Structure definition
struct My_Struct
  {
   datetime          s_time;
   double            s_price;
  };

//array of My_Struct
My_Struct Basic_Struct[];


I need to get iMaOnArray from Basic_Struct[index].s_price

Is it possible? If yes, how?

Thank you

Ovo Cz
2958
Ovo Cz 2015.10.15 11:35  
ggekko:

Hi Gurus,

I can get iMaOnArray from an array, like this:


My question: is it possible to get iMaOnArray from an element of a structure?

Let's say I have this structure:


I need to get iMaOnArray from Basic_Struct[index].s_price

Is it possible? If yes, how?

Thank you


No. If the declaration reads double, you cannot pass another type.
Gordon Gekko
647
Gordon Gekko 2015.10.15 12:07  
Ovo:
No. If the declaration reads double, you cannot pass another type.

Yes, I thought. Too bad ..

Thank you for your answer.

whroeder1
13596
whroeder1 2015.10.15 16:51  
You'll have to write your own.
Not compiled, not tested.
double  iMAOnBasic_Struct(
   const Basic_Struct& array[]    // array with data
   int          total,            // number of elements
   int          ma_period,        // MA averaging period
   int          ma_shift,         // MA shift
   int          ma_method,        // MA averaging method
   int          shift             // shift
   ){
  double values[]; ArrayResize(values, total);
  for(int i=0; i < total; ++i) values[i] = Basic_Struct[i + shift].s_price;
  retur iMAOnArray(values, total, ma_period, ma_shift, ma_method, 0);
}
Not compiled, not tested.
Gordon Gekko
647
Gordon Gekko 2015.10.17 11:10  
WHRoeder:
You'll have to write your own.
Not compiled, not tested.Not compiled, not tested.

Thank you for your answer. My problem is that this solution do not give a direct access to iMAOnArray.

I know I can load the values through a cycle

for(int i=0; i < total; ++i) values[i] = Basic_Struct[i + shift].s_price;

but I would have liked a direct access without making a plus array (because the speed).

Thank you again!

/
To add comments, please log in or register