Download MetaTrader 5
To add comments, please log in or register
Publish your article and thousands of people all over the world will read it!
jshumaker
507
jshumaker 2013.03.24 13:50 

I want to try to count wave patterns in my EA and see the wave counts on the chart.  Do I need to create a custom indicator and attach that indicator to the template file and access the custom indicator in the EA or can I call a function to draw an object on the charts directly from the EA?

I have just started researching how to use PlotIndexSet... functions work but all the code samples I have seen use the OnCalculate function.  Which as far as I can tell, OnCalculate is only for custom indicators and not for EAs.  

 

Documentation on MQL5: Language Basics / Functions / Event Handling Functions
Documentation on MQL5: Language Basics / Functions / Event Handling Functions
  • www.mql5.com
Language Basics / Functions / Event Handling Functions - Documentation on MQL5
Alain Verleyen
Moderator
28522
Alain Verleyen 2013.03.24 14:04  
jshumaker:

I want to try to count wave patterns in my EA and see the wave counts on the chart.  Do I need to create a custom indicator and attach that indicator to the template file and access the custom indicator in the EA or can I call a function to draw an object on the charts directly from the EA?

I have just started researching how to use PlotIndexSet... functions work but all the code samples I have seen use the OnCalculate function.  Which as far as I can tell, OnCalculate is only for custom indicators and not for EAs.  

 

From documentation :

These functions can't be used when writing Expert Advisors and Scripts.

So you have either to create Objects directly in your EA or use a Custom indicator.

jshumaker
507
jshumaker 2013.03.24 17:03  
angevoyageur:

From documentation :

So you have either to create Objects directly in your EA or use a Custom indicator.

ObjectCreate(0,"prevHigh",OBJ_ARROW_SELL,0,TimeCurrent(),1.453);    
I added that line to my EA and I do not see the arrows on the chart
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2013.03.24 17:27  
jshumaker:
I added that line to my EA and I do not see the arrows on the chart
Was the value  1.453   on your chart at the time ?   try placing the arrow at Bid or Ask price instead, that is guaranteed to be visible on your chart. 
jshumaker
507
jshumaker 2013.03.24 17:29  
RaptorUK:
Was the value  1.453   on your chart at the time ?   try placing the arrow at Bid or Ask price instead, that is guaranteed to be visible on your chart. 
   ObjectCreate(0,"prevHigh",OBJ_ARROW_SELL,0,TimeCurrent(),m_symbol.Bid());  
still nothing
Alain Verleyen
Moderator
28522
Alain Verleyen 2013.03.24 17:32  
jshumaker:
I added that line to my EA and I do not see the arrows on the chart
Is the value returned by ObjectCreate() equal true or false ?
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2013.03.24 17:37  
jshumaker:
still nothing

Maybe you need to explicitly give it a colour ?

ObjectCreate(0,"prevHigh",OBJ_ARROW_SELL,0,TimeCurrent(),m_symbol.Bid());  
ObjectSetInteger(0, "prevHigh", OBJPROP_COLOR, Yellow);  
Alain Verleyen
Moderator
28522
Alain Verleyen 2013.03.24 17:43  
Ah ok, I understood. Objects are not plotted when backtesting :-D
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2013.03.24 18:24  
angevoyageur:
Ah ok, I understood. Objects are not plotted when backtesting :-D
Maybe not Optimization but aren't they plotted during visual mode ?  I hope they are . . .  but haven't tried.  They are from an Indicator.
Alain Verleyen
Moderator
28522
Alain Verleyen 2013.03.24 18:38  
RaptorUK:
Maybe not Optimization but aren't they plotted during visual mode ?  I hope they are . . .  but haven't tried.  They are from an Indicator.
This limitation does not apply to testing in visual mode.
RTFM ;-)
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2013.03.24 19:12  
angevoyageur:
RTFM ;-)
At least one of us is confused  ;-)
/ /12
To add comments, please log in or register