Indicator cannot get object created in EA

 

Hi, I'm trying to pass some values from EA to a custom indicator and vice versa. So It's a two way communication.
I'm using MQL4.

I do it by creating chart objects in the EA, which contain the value I want to pass to the indicator. I encode the value in the object description.
When I call iCustom, I expect the indicator to find the created objects and build a moving average out of those values.

Problem is, when I backtest the EA, my custom indicator seems unable to detect any object in the chart. ObjectsTotal always return 0 when called from inside the indicator.
But strange thing is, when the backtest is running and I plop my custom indicator, it renders the moving average as intended.
But calling it from iCustom seems to make the indicator cannot read any object in the chart.

I've placed print after the ObjectCreate in the EA and before ObjectFind in the indicator, and I can confirm that ObjectCreate is called before ObjectFind is called.
So I assume that the object has been created before the ObjectFind call.

Can someone explain the reason for this behavior ?

I don't post my code because I the explanation above is enough to explain what I'm trying to say, and also the code is just too long,
but anyway let me know if you need to see some code example.


Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Properties
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Properties
  • www.mql5.com
Object Properties - Objects Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Bondan Sebastian: Problem is, when I backtest the EA, my custom indicator seems unable to detect any object in the chart. ObjectsTotal always return 0 when called from inside the indicator.

As per the documentation, the Strategy Tester does not support nor render graphical objects, unless it is in Visual Mode.

Graphical Objects in Testing

During testing/optimization graphical objects are not plotted. Thus, when referring to the properties of a created object during testing/optimization, an Expert Advisor will receive zero values.

This limitation does not apply to testing in visual mode.


 
Fernando Carreiro #:

As per the documentation, the Strategy Tester does not support nor render graphical objects, unless it is in Visual Mode.

Graphical Objects in Testing

During testing/optimization graphical objects are not plotted. Thus, when referring to the properties of a created object during testing/optimization, an Expert Advisor will receive zero values.

This limitation does not apply to testing in visual mode.


Thanks for the link. Actually I'm using MT4 not MT5, but from there I can find the docs for MT4. 
This is what it says:

Graphical Objects in Testing

During visualization, the Expert Advisor interacts with a real chart. In case there is no visualization, the Expert Advisor works with a "virtual" chart that is not displayed. The former case has some peculiarities. During optimization, working with graphical objects is not supported.

In my case, the visualization is active for the EA, but not for the indicator.
So I guess the EA is running in the real chart environment while the indicator runs in the "virtual" chart environment, therefore explaining why the indicator can't detect any object from the chart.
I'm not 100% sure that my conclusion is correct, would be thankful if someone with better experience can confirm it.
 

Please don't post randomly in any section. Your question is not related to the section you posted.

MT4/mql4 has it's own section on the forum.

I have moved your topic to the correct section later, please don't create another topic.

 
Bondan Sebastian #: Thanks for the link. Actually I'm using MT4 not MT5, but from there I can find the docs for MT4. 

This is what it says:

Graphical Objects in Testing

During visualization, the Expert Advisor interacts with a real chart. In case there is no visualization, the Expert Advisor works with a "virtual" chart that is not displayed. The former case has some peculiarities. During optimization, working with graphical objects is not supported.

In my case, the visualization is active for the EA, but not for the indicator.
So I guess the EA is running in the real chart environment while the indicator runs in the "virtual" chart environment, therefore explaining why the indicator can't detect any object from the chart.
I'm not 100% sure that my conclusion is correct, would be thankful if someone with better experience can confirm it.

I am unsure of the your exact specifics, so cannot comment much — Graphical objects in testing

However, are your Indicators perhaps running "hidden"? Did you try not "hiding" them?

Operation of Programs in the Strategy Tester - MQL4 programs - MQL4 Reference
Operation of Programs in the Strategy Tester - MQL4 programs - MQL4 Reference
  • docs.mql4.com
Operation of Programs in the Strategy Tester - MQL4 programs - MQL4 Reference
 
Alain Verleyen #:

Please don't post randomly in any section. Your question is not related to the section you posted.

MT4/mql4 has it's own section on the forum.

I have moved your topic to the correct section later, please don't create another topic.

Apologize, thank you for moving

 
Fernando Carreiro #:

I am unsure of the your exact specifics, so cannot comment much — Graphical objects in testing

However, are your Indicators perhaps running "hidden"? Did you try not "hiding" them?

Well, yes I hide it, but not "hiding" them still bear the same result

Reason: