_AppliedTo passed to iCustom but not being set in indicator - page 2

 
Richard Segrue #The method you've suggested would only allow me to get data from one indicator through the price[] array passed  via OnCalculate but not from the other indicator. So it would work for 1 indicator but not 2+.

Your explanation is still unclear because I think you are still mixing up concepts.

You don't get data from an indicator via the price[]. "price[]" is not an output, it is is an input.

Indicators output buffers or plots and to access an indicator's "output", you use the CopyBuffer() function.

The only special case is when you want to feed the output of one indicator (it's first buffer), into the price[] input of another indicator to build a kind of "pipe" functionality. But this, does not seem to be what you are trying to achieve.

As far as I can tell, you are simply wanting to access the output data of indicators, be it one or many buffers or plots, and for that you should use the CopyBuffer() function.

Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
  • www.mql5.com
Gets data of a specified buffer of a certain indicator in the necessary quantity. Counting of elements of copied data (indicator buffer with the...
 
Richard Segrue #:

What I wanted to do was create 2 indicators with iCustom within my master and within the oncalculate of the master, copy the data from each indicator and calculate a new indicator buffer. What I was trying to achieve by passing the _AppliedTo to each slave indicator was ensure they were using the same Applied Price as the master.

Yes, this is surely doable and makes sense. You just need to use the short form of OnCalculate.

 
Fernando Carreiro #:

After reading your initial post again, I think that you and I may be misunderstanding each other. So I am going to try re-explain things.

  1. I am assuming that a "slave" indicator, is one that simply produces a normal output, be it one or more buffers. Nothing special, and any ordinary indicator will do.
  2. I am assuming that a "master" indicator, is one that requires an "applied price" as input, which could simply be one of the default ones such Close, Median, Typical, etc.
  3. I am assuming that you want to feed the output of the "slave" as an input to the applied price of the "master" indicator.

Now, with that in mind, your initial post does not actually reflect that. In your code sample, your supposed "master" is trying to "inject" an applied price into an indicator that is supposedly the "slave" which was not designed for an applied price.

So, trying to clarify your issue, it seems that you first need to understand that there are two types of indicators:

  1. one that requires an applied price as an input.
  2. another that uses the full OHLC bar data as input.

These two types are defined by what format their OnCalculate() event handlers takes:

Only the first format can take an applied price as an input.

Now, if you simply want to use standard applied price for the first format, then you don't need to any of this "master"/"slave" relationship. Just call the iCustom() function normally and define which price you want applied.

In essence, I may have misunderstood your question with your "master"/"slave" description.

Just use the first format of OnCalculate() in your indicator, and apply a price with your call to iCustom(), with the last parameter being the applied price.

Calling code:

Indicator code:

Hope that helps clarify a few things!

Have had another read of this with a fresh mind this morning and my fog is slowly rising. 

Appreciate the explanation. I now need to code it and see things working.

Thanks for your patience and time Fernando

 
Stanislav Korotky #:

Yes, this is surely doable and makes sense. You just need to use the short form of OnCalculate.

Thanks Stanislav. I did use the short form also and still had the issue that _AppliedTo in the slave indicators was not showing the value passed into iCustom. I don't think that's important now though, it was the wrong test from a misunderstanding of the architecture. I was assuming that the slave indicators got their own data input rather than taking the input from the master indicator. So the slave indicators don't need to know the _AppliedTo, they just take input from prices[] in oncalculate. At least this is my current understanding , it's subject to change as my idiocy fades so feel free to correct me if it shows misunderstandings.

 
Richard Segrue #:

Thanks Stanislav. I did use the short form also and still had the issue that _AppliedTo in the slave indicators was not showing the value passed into iCustom. I don't think that's important now though, it was the wrong test from a misunderstanding of the architecture. I was assuming that the slave indicators got their own data input rather than taking the input from the master indicator. So the slave indicators don't need to know the _AppliedTo, they just take input from prices[] in oncalculate. At least this is my current understanding , it's subject to change as my idiocy fades so feel free to correct me if it shows misunderstandings.

That's incorrect. Your main indicator can technically invoke slave indicators for any data series different to the data used by the main, even for different symbol and timeframe. I'm not sure, if _AppliedTo is passed implicitly behind the scenes from the main indicator to subsidiaries.

 

I can confirm: there is STILL a bug that _AppliedTo is not reported to subsidiary indicators created via iCustom(..., _AppliedTo).

Initially reported in 2024.

_AppliedTo Return 0 When Calling iCustom
_AppliedTo Return 0 When Calling iCustom
  • 2024.02.13
  • www.mql5.com
Hi, I'm testing some features, and am stuck trying to use data from another indicator using iCustom() The goal is that I want to pass applied price...
 
Stanislav Korotky #:

I can confirm: there is STILL a bug that _AppliedTo is not reported to subsidiary indicators created via iCustom(..., _AppliedTo).

Initially reported in 2024.

Thanks for finding that out. I did come across that forum post but assumed it could have been user error rather than a confirmed bug. I'll work on a test example to get it working another way which I'm considering based on conversations with Fernando. Once done I'll post here. May take a while as other things have been put on hold while I've been down this rabbit hole.
 
Richard Segrue #:
Thanks for finding that out. I did come across that forum post but assumed it could have been user error rather than a confirmed bug. I'll work on a test example to get it working another way which I'm considering based on conversations with Fernando. Once done I'll post here. May take a while as other things have been put on hold while I've been down this rabbit hole.
The only workaround that I know is to add a dedicated input variable to the slave indicators and use it by the master indicator to pass required kind of series into the slaves.