Problem with double/double

Back to topics list To post a new topic, please log in or register
avatar
4
ndbd79 2016.06.26 03:20
 

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!

avatar
4
ndbd79 2016.06.26 07:38 #
 
Please help me!
avatar
2017
gooly 2016.06.26 09:09 #
 

What is your problem? Errorcode? ..?

Sorry but my crystal ball has a crack. :(

avatar
12985
WHRoeder 2016.06.26 14:24 #
 
      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?
avatar
4
ndbd79 2016.06.26 15:13 #
 

Thanks for answer,

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

When I try degug the MT4 close!




avatar
12985
WHRoeder 2016.06.26 20:47 #
 
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.

avatar
4
ndbd79 2016.06.28 09:19 #
 
 

  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!


avatar
1200
FMIC 2016.06.28 09:36 #
 

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!

Back to topics list  

To add comments, please log in or register