ONE indicator writes TWO output windows ? - page 2

 
gooly:

do s.th. with s.o.



Do something with someone XD
 

hmm - shouldn't this look like:

double m_Buffer[];
...
int OnInit()
  {
//--- indicator buffers mapping
   IndicatorBuffers( 1 );
   SetIndexBuffer( 0, m_Buffer);
   SetIndexStyle( 0, DRAW_LINE, STYLE_SOLID, 2 );

//---
   return(INIT_SUCCEEDED);
  }

int OnCalculate( .. ) {
  ...
  for(int pos = maxBars - itsPeriods; pos >= start; pos--)
   {
      // in two lines for better understanding
      double singleValue = iCustom(Symbol(), PERIOD_D1, "myIndicator", itsPeriods, 0, pos);
      m_Buffer[pos] = singleValue;
   }  
...  
 
gooly:

hmm - shouldn't this look like:

Yes, but let me explain my hopes with some code (first part is working). This is only for demonstration and not usefull because it depends hardcoded on a special environment.

1) An Include-File. It carrys the Buffer global !

//+------------------------------------------------------------------+
//|                                     testStructureAndFunction.mqh |
//|                                                         Abejorro |
//+------------------------------------------------------------------+
#property copyright "Abejorro"
#property link      "not yet"
#property strict

double realPublicBuffer[];
....


2) One Indicator uses this Buffer directly for writing. This is the main-player for generating the content in there:

#include <testStructureAndFunction.mqh>

//--- indicator buffers mapping - not locals !
   
   SetIndexBuffer( 0, realPublicBuffer);
   SetIndexStyle( 0, DRAW_LINE, STYLE_SOLID, 2 );

   // calculating, calculating, calculating...
   realPublicBuffer[2] = 12;  // sometimes the value may be different :-)


3) If Part 2 is finished, all others could use the totally filled Buffer with using this include. Without recalculating and wasting cpu-time. But here is the first issue: Every indicator is going to work in his own threat as I learned ?!?

And, it is not nice because the names are hardcoded. This is a point to request a dynamic solution, a pointer or so ...


There is no smart way for that ?

Reason: