Download MetaTrader 5

Syntax of iAO

To add comments, please log in or register
Jerry Spence
216
Jerry Spence 2010.01.31 04:05 

In MT4 I have:

A1 = iAO(NULL, PERIOD_H1, 1);

Reading the MT5 documentation I don't understand how to get it to work. It complains that the parameter count is wrong. It hasn't got the last item, so how do I extract the nth bar information?

The documentation says:

The function creates Accelerator Oscillator in a global cache of the client terminal and returns its handle. It has only one buffer.

Which doesn't really help very much. I wish the help file would contain examples as it is so much easier to understand.

-Jerry

Accelerator Oscillator (AC)
  • votes: 21
  • 2010.01.06
  • MetaQuotes Software Corp. | English Russian Chinese Spanish Portuguese
  • www.mql5.com
The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.
Andriy Moraru
1261
Andriy Moraru 2010.01.31 11:32  

In MT5 you don't get the shifted value of the indicators directly from the function call. First, you get the handle:

AOhandle = iAO(NULL, PERIOD_H1);

Then you copy the buffer from the handle:

double AObuffer[];
CopyBuffer(AOhandle, 0, 0, rates_total, AOhandle);

Now you can use the separate elements of the buffer. If you want classic timeseries order where the 9th element is 9 periods ago you should also set the buffer as series:

ArraySetAsSeries(AObuffer, true);
double AO_9 = AObuffer[9];
        
Jerry Spence
216
Jerry Spence 2010.01.31 16:41  
enivid:

In MT5 you don't get the shifted value of the indicators directly from the function call. First, you get the handle:

Then you copy the buffer from the handle:

Now you can use the separate elements of the buffer. If you want classic timeseries order where the 9th element is 9 periods ago you should also set the buffer as series:

Very many thanks. I was trying to get my head around the new way of extracting data. I think your example should go in the MT5 help file!

-Jerry

Jerry Spence
216
Jerry Spence 2010.01.31 16:42  
enivid:

In MT5 you don't get the shifted value of the indicators directly from the function call. First, you get the handle:

Then you copy the buffer from the handle:

Now you can use the separate elements of the buffer. If you want classic timeseries order where the 9th element is 9 periods ago you should also set the buffer as series:

Very many thanks. I was trying to get my head around the new way of extracting data. I think your example should go in the MT5 help file!

-Jerry

Jerry Spence
216
Jerry Spence 2010.01.31 16:43  
netconuk:

Very many thanks. I was trying to get my head around the new way of extracting data. I think your example should go in the MT5 help file!

-Jerry

Actually for correctness I think it should be this (but you knew that!
CopyBuffer(AOhandle, 0, 0, rates_total, AOBuffer);
Andriy Moraru
1261
Andriy Moraru 2010.02.01 12:00  
netconuk:
Actually for correctness I think it should be this (but you knew that!
Yeah, sorry, mistyped it.
To add comments, please log in or register