Awesome Oscillator 5min and 30min variable

 

Hi!

I am trying to code a Awesome Oscillator that works on different timeframes. So for example the chart is a 30min timeframe, but the indicator works on a 5min timeframe. 

This is available on the trading view Awesome Oscillator, but I can't figure out how to code it. When you add or change the settings of the AO you have the option to choose the timeframe that the indicator is in.

Can someone please explain how this is calculated? 

I hope to hear from you soon.

Thanks in advance.

yours sincerely,

Daan

 
DaanKouwen_SF: I am trying to code a Awesome Oscillator that works on different timeframes.

No need; it works on all TF. Just read the indicator from the TF (second parameter) you want. Adjust the shift to the TF with iBarShift.

 
William Roeder:

No need; it works on all TF. Just read the indicator from the TF (second parameter) you want. Adjust the shift to the TF with iBarShift.

Thank you for your answer!

So how do I get the right shift, like in trading view? -> I probably mis-use the iBarShift. What is supposed to be in the "time" section of the iBarShift?

double CurrentAOValue()
{
        return iAO(Symbol(),PERIOD_M30,iBarShift(Symbol(),PERIOD_M5,???TIME???,false));
}
 
William Roeder:

No need; it works on all TF. Just read the indicator from the TF (second parameter) you want. Adjust the shift to the TF with iBarShift.

It is like this in trading view:

https://www. tradingview.com/x/Di2NDP9b/
 
DaanKouwen_SF: So how do I get the right shift, like in trading view? -> I probably mis-use the iBarShift. What is supposed to be in the "time" section of the iBarShift?

Only you know what you are trying to achieve. There are multiple M5 bars worth of data for one M30. Which one are you going to use?

 
William Roeder:

Only you know what you are trying to achieve. There are multiple M5 bars worth of data for one M30. Which one are you going to use?


I actually do not know which... I am trying to recreate the indicator that is shown in the trading view screenshot. 

I asked a well known pinescript coder how this is achieved in pinescript.  He replied the following:

------------------------------

Do you user this function?


Use security function for get other TF and set it for indicator

-----------------------------

That is supposed to be the way to calculate the indicator in pinescript, but I can't figure out how to make this in MQL4 with my lacking knowledge...

Do you know how to make this in MQL4 or is there a method to achieve this? 


What I try to make is the following (better explanation):

I want to make the Awesome Oscillator from tradingview into MQL4, so I can use this in a EA. 

When you add the Awesome Oscillator to a chart you can change the timeframe the indicator is working on (see attached file).


This changes the values of the indicator. But I do not know how this is done, in the lower left corner you can see all the code that is available of this indicator. 

Do you understand how the method the guy from trading view mentioned works, and if there is a way to implement that into MQL4?


I hope to hear from you soon!

Thanks in advance!

Daan

Files:
Reason: