You are right, buffers can only be of 'double' type.
In your case you should use 3 buffers converting your struct values to double.
Let me rephrase the original question as below.
If I use the above structure as it is in the indicator without defining it as Indicator Buffer.
How can I retrieve its values in an EA or OOP Class?
As I assume CopyBuffer() should work only on indicator buffer(s).Try declaring a public double array as part of the struct and Setting it as indicator buffer? Not sure it works though.
Hi Tobias
Below is the CopyBuffer() as per documentation.
int CopyBuffer( int indicator_handle, // indicator handle int buffer_num, // indicator buffer number int start_pos, // start position int count, // amount to copy double buffer[] // target array to copy );
You can see it requires a double buffer[], so anything else will not work.
Hi Tobias
Below is the CopyBuffer() as per documentation.
You can see it requires a double buffer[], so anything else will not work.
struct SBuf { int handle; double buf[]; SBuf():handle(INVALID_HANDLE){;} }; SBuf bufStruct; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- bufStruct.handle = iMomentum(_Symbol, _Period, 7, PRICE_TYPICAL); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- CopyBuffer(bufStruct.handle, 0, 0, 10, bufStruct.buf); for(int i=0;i<ArraySize(bufStruct.buf);i++) { PrintFormat("buf[%d] = %g",i,bufStruct.buf[i]); } } //+------------------------------------------------------------------+
Can this be of use to you?
Thanks @Tobias Johannes Zimmer
This is an interesting idea when one wants to use another indicator data into an indicator. However same results will be achieved without using the 'structure array'.
In my case the multiple values are calculated within the indicator and they are related (linked) to a particular bar index. e.g. three values of Pivot Range Top Central, Pivot Range Point and Pivot Range Bottom Central are linked to daily bar index.
Now I will be running this indicator on intraday chart(s) so it will have many bars which correspond to a single day.
It is bit more complex issue than just what you think. Anyways THANKS A LOT for your efforts and consideration.
Regards
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Wish all happy beginning of the week.
I have following structure and want to use its information in the Indicator Buffer(s). To my understanding indicator buffers are allowed only of 'double' type.
Is there any work around to what I want to achieve?