How to detect the source when a custom indicator is called? - page 2

 
phi.nuts:

You could do this actually,

Anyway, from that 7 buffers you show, which one you don't want to use and where does this buffer get the data ( say for example the data you don't want to use is buffer 6 which get the data from buffer 0) ?

 

I got it!!!. You're my hero.

 

The "iEACalculationMode" boolean is standard set to "true" in the code.  

The EA imports all the indicator data with the iCustom() function with it's default input settings/values. 

 

The "iEACalculationMode" boolean value of the 2e custom indicator, which is attached to the chart is manually set to "false" in the inputs settings TAB.

This boolean switches off the calculation of the additional data (see code).

 

Problem solved.

 

Thanks!!! 

   
input bool iEACalculationMode = true;  // EA calculation version.



int OnInit()
  {

// Indicator buffers mapping.
   SetIndexBuffer(0,  LTerm_UpperLine,                   INDICATOR_DATA);
   SetIndexBuffer(1,  LTerm_LowerLine,                   INDICATOR_DATA);
   SetIndexBuffer(2,  STerm_UpperLine,                   INDICATOR_DATA);   
   SetIndexBuffer(3,  STerm_LowerLine,                   INDICATOR_DATA);
   SetIndexBuffer(4,  DAY_UpperLine,                     INDICATOR_DATA);   
   SetIndexBuffer(5,  DAY_LowerLine,                     INDICATOR_DATA);

// activate the additional buffer.
  if(iEACalculationMode == true)  SetIndexBuffer(6,  LTerm_RecentIndicatorSupportData,  INDICATOR_CALCULATIONS);   
  }



int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {

// standard indicator data (6 indicator buffer data).
//---------------------------------------------------

  code

// Additional data (7e indicator buffer data).
//-----------------------------------------------------------
  if(iEACalculationMode == true) // EA calculation check mode.          
       {     
       code     
       }

  }





Step on New Rails: Custom Indicators in MQL5
Step on New Rails: Custom Indicators in MQL5
  • 2009.11.23
  • Андрей
  • www.mql5.com
I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
 
But this input is true by default!
Did you try my approach?
 
codersguru:
But this input is true by default!
Did you try my approach?

The value needs to be true by default, because the EA is always loading the default values.

I manually switch the value to false for the custom indicator that is attached to the chart. 

 

Yes I did also your approach but your method works when only the EA is attached to the chart.

When I include the custom indicator to the same chart, the call from the EA is no longer recognized and then this method becomes useless.