Problem with double/double

 

Hi all,


I have a problem with code:

#property indicator_separate_window    // Indicator is drawn in the main window
#property indicator_buffers 2       // Number of buffers
#property indicator_color1 Blue     // Color of the 1st line
#property indicator_color2 Red      // Color of the 2nd line
 
double Buf_0[],Buf_1[];             // Declaring arrays (for indicator buffers)
//--------------------------------------------------------------------
int init()                          // Special function init()
  {
   SetIndexBuffer(0,Buf_0);         // Assigning an array to a buffer
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);// Line style
   SetIndexBuffer(1,Buf_1);         // Assigning an array to a buffer
   SetIndexStyle (1,DRAW_LINE,STYLE_DOT,1);// Line style
   return;                          // Exit the special funct. init()
  }
//--------------------------------------------------------------------
int start()                         // Special function start()
  {
   int i,                           // Bar index
       Counted_bars;                // Number of counted bars
   double Buf1=0.0,Buf2=0.0,Buf3=0.0,Buf4=0.0;    
//--------------------------------------------------------------------
   Counted_bars=IndicatorCounted(); // Number of counted bars
   i=Bars-Counted_bars-1;           // Index of the first uncounted
   
   while(i>=0)                      // Loop for uncounted bars
     {
      Buf1=iClose("EURUSD",0,i);
      Buf2=iClose("GBPUSD",0,i);
      Buf_0[i]=Buf1/Buf2;             // Value of 0 buffer on i bar
      Buf_1[i]=iClose("GBPUSD",0,i);              // Value of 1st buffer on i bar
      i--;                          // Calculating index of the next bar
     }
//--------------------------------------------------------------------
   return;                          // Exit the special funct. start()
  }


Indicator can't load!

Help  me!

Thanks!

 
Please help me!
 

What is your problem? Errorcode? ..?

Sorry but my crystal ball has a crack. :(

 
      Buf1=iClose("EURUSD",0,i);
      Buf2=iClose("GBPUSD",0,i);
      Buf_0[i]=Buf1/Buf2;             // Value of 0 buffer on i bar
      Buf_1[i]=iClose("GBPUSD",0,i);              // Value of 1st buffer on i bar
(EUR/USD) / (GBP/USD) = EUR/GBP. Are you expecting the GBP/USD to be close?
 

Thanks for answer,

Why indicator can't run with Buf_0[i]=Buf1/Buf2;

When I try degug the MT4 close!




 
ndbd79: Why indicator can't run with Buf_0[i]=Buf1/Buf2;

When I try degug the MT4 close!

  1. Certainly can.
  2. Some other problem, which you don't give any information, therefor no one can help you.
 
 

  1. Certainly can.
  2. Some other problem, which you don't give any information, therefor no one can help you.

I want to ask : why I can't divide double/double!

My code did puplic.

Screenshot mt4 indicator. It's empty!


 

It can divide double by double, but it can't divide "double / ZERO". The reason you are getting a ZERO for the divisor, is because your indicator is a multi-currency indicator and you must certify that the data is available at the time it runs and there is a delay for the terminal to get the other data.

There are many complications when coding a multiple currency indicator, so please read the following thread completely for more information (that is EVERY post from beginning to the end, don't skip any posts).


PS! Please note that dividing "EURUSD" by "GBPUSD" is the same as "EURGBP". So just read the symbol "EURGBP" directly instead of dividing the two symbols!

Reason: