draw arrows in EA

 

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
 
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.

 
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
 
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. 
 
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
 
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 ?
 
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);  
 
Ah ok, I understood. Objects are not plotted when backtesting :-D
 
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.
 
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 ;-)
 
angevoyageur:
RTFM ;-)
At least one of us is confused  ;-)
Reason: