empty values in custom indicators

 

Hi every body,

I have wrote an custom Indicator(A) like zigzag, and it works fine, 

however the problem is when I call it in to another custom Indicator(B) it refers "2.781888206090574e-308" for empty values.

As an example, A(10)= empty values, means the value of Indicator "A" in candle "10" is equal to " empty values' ;

now, I need A(10) in Indicator B, write c= A(10);

but c= 2.781888206090574e-308 instead of empty values or zero.

 
 CONSTANT  DESCRIPTION  VALUE

EMPTY_VALUE

Empty value in an indicator buffer

DBL_MAX

  DBL_MAX   Maximal value, which can be represented by double type  

1.7976931348623158e+308

EMPTY_VALUE is stored as DBL_MAX by default.

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Other Constants
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Other Constants
  • www.mql5.com
The CLR_NONE constant is used to outline the absence of color, it means that the graphical object or graphical series of an indicator will not be...
 
Yashar Seyyedin #:
 CONSTANT  DESCRIPTION  VALUE

EMPTY_VALUE

Empty value in an indicator buffer

DBL_MAX

  DBL_MAX   Maximal value, which can be represented by double type  

1.7976931348623158e+308

EMPTY_VALUE is stored as DBL_MAX by default.

thanks dear,

but it refers to  "2.781888206090574e-308" not "1.7976931348623158e+308"

 

and another Q

first of all I'm not very good in MQL5,is this true to call(means handle and copy and ...) an custom indicator by a function in "Include file", to use for all other Indicator ?

 

EMPTY_VALUE can also be  -DBL_MAX

If you want it to be zero then why don't you just make it equal to 0 instead of EMPTY_VALUE

 
Conor Mcnamara #:

EMPTY_VALUE can also be  -DBL_MAX

If you want it to be zero then why don't you just make it equal to 0 instead of EMPTY_VALUE

I have make them zero by ArrayInitialize(Buffer_0, 0.0) in OnCalculate() part in prev_calculated == 0

but it doesn't work or something else is wrong.

 
Asa Sh #:
an custom indicator by a function in "Include file", t
No. To invoke a custom indicator in a separate EA or indicator it is best to apply iCustom function.
 
Asa Sh #:
refers to  "2.781888206090574e-308" not "1.7976931348623158e+308"
You should share more details including your sources.
 
Yashar Seyyedin #:
You should share more details including your sources.

This is My Custom Zizag indicator A:

<Improperly formatted code removed by moderator>

actually I want to use Zigzag Indicator of higher Timeframe (A) in lower Timeframe

MQL5.community - User Memo
MQL5.community - User Memo
  • www.mql5.com
You have just registered and most likely you have questions such as, "How do I insert a picture to my a message?" "How do I format my MQL5 source code?" "Where are my personal messages kept?" You may have many other questions. In this article, we have prepared some hands-on tips that will help you get accustomed in MQL5.community and take full advantage of its available features.
 

When you post code please use the CODE button (Alt-S)!

Use the CODE button

Thank you.

 
Yashar Seyyedin #:
You should share more details including your sources.

This is My Custom Zizag indicator:

//+---------------------------------------------------------------------------------------+ Calculation +---------------------------------------------------------------------------------+
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[])
{
   ArraySetAsSeries(time, true);
   ArraySetAsSeries(open, true);
   ArraySetAsSeries(high, true);
   ArraySetAsSeries(low, true);
   ArraySetAsSeries(close, true);
   ArraySetAsSeries(tick_volume, true);
   ArraySetAsSeries(volume, true);
   ArraySetAsSeries(spread, true);
//+---------------------------------------------------------------------------------------+ Constants
   int    q = 0, mystart = 0, counterZ = 0, whatlookfor = Extremum;
   int    i = 0, pos = 0, back = 0, lasthighpos = 0, lastlowpos = 0;//
   double val = 0, res = 0;
   double curlow = 0.0, curhigh = 0.0, lasthigh = 0.0, lastlow = 0.0;
   int    t = MyTimeFrameNum(Period());
//+---------------------------------------------------------------------------------------+ ReInit
   if(iVolume(MySymbol, MyTimeFramesMQL4(0), 0) <= 1)
   {
      
	//--- 
      IsDrawn = 0;
      mystart = InitializeAll();
   }
//+---------------------------------------------------------------------------------------+ Calculation
   if(rates_total < InpDepth || InpBackstep >= InpDepth)
      return(0);
//----------------------------------------------------------------------------------------+ first calculations
   if(prev_calculated == 0)
   {
      
	//--- 
      IsDrawn = 0;
      mystart = InitializeAll();
   }
   else
   {
      //--- find first val in the depth ExtLevel or 100 last bars
      q = counterZ = 0;
      while(counterZ < ExtLevel && q < 100)
      {
         if(Line_0[q] != 0.0)
            counterZ++;
         q++;
      }
      //--- no val found - recounting all from begin
      if(counterZ == 0)
         mystart = InitializeAll();
      else
      {
         //--- set mystart position to found val position
         mystart = q - 1;
         //--- what kind of val?
         if(Line_2[q] != 0.0)
         {
            //--- low val
            curlow = Line_2[q];
            //--- will look for the next high val
            whatlookfor = Peak;
         }
         else
         {
            //--- high val
            curhigh = Line_1[q];
            //--- will look for the next low val
            whatlookfor = Bottom;
         }
         //--- clear the rest data
         for(q = mystart - 1; q >= 0; q--)
         {
            Line_0[q] = 0.0;
            Line_2[q] = 0.0;
            Line_1[q] = 0.0;
            Line_3[q] = 0.0;
            Line_4[q] = 0.0;
            Line_5[q] = 0.0;
            Line_6[q] = 0.0;
            Line_7[q] = 0.0;
            Line_8[q] = 0.0;
            Line_9[q] = 0.0;
            Line_10[q] = 0.0;
            Line_11[q] = 0.0;
            Line_12[q] = 0.0;
            Line_13[q] = 0.0;
            Line_14[q] = 0.0;
            ObjectDelete(ChID, IndicatorTagName + "Leg_" + MyTimeFrameNames[t] + "_" + (string) q);
         }
      }
   }
//--- main loop
   for(i = mystart; i >= 0; i--)
   {
      //---
   }
//+---------------------------------------------------------------------------------------+ return
   return(rates_total);
}
//+---------------------------------------------------------------------------------------+ ReInit
int InitializeAll()
{
   ArrayInitialize(Line_0, 0.0);
   ArrayInitialize(Line_1, 0.0);
   ArrayInitialize(Line_2, 0.0);
   ArrayInitialize(Line_3, 0.0);
   ArrayInitialize(Line_4, 0.0);
   ArrayInitialize(Line_5, 0.0);
   ArrayInitialize(Line_6, 0.0);
   ArrayInitialize(Line_7, 0.0);
   ArrayInitialize(Line_8, 0.0);
   ArrayInitialize(Line_9, 0.0);
   ArrayInitialize(Line_10, 0.0);
   ArrayInitialize(Line_11, 0.0);
   ArrayInitialize(Line_12, 0.0);
   ArrayInitialize(Line_13, 0.0);
   ArrayInitialize(Line_14, 0.0);
//--- first counting j1ition
   return(iBars(NULL, PERIOD_CURRENT) - InpDepth);
}

This is My Custom function in include file to refer Indicator A:

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Legs(long A_ChID,
            string A_MySymbol,
            bool A_extern1,
            bool A_extern2,
            bool A_extern3,
            int t, //timeframe
            int d, //buffer
            int i //Candle bar number
) 
{
   ChartRedraw();
   int Handle = iCustom(A_MySymbol, MyTimeFramesMQL4(t), "A");
   double p = 0;
   double MyLegsIndicator[];

   int copy = CopyBuffer(Handle, d, i, 1, MyLegsIndicator);
   p = MyLegsIndicator[0];
   return(p);

Actually I want to use Zigzag Indicator of higher Timeframe (A) in lower Timeframe by:

Legs(A_ChID, A_MySymbol, false, false, false, t, 3, i);

current timeframe is different to t