Download MetaTrader 5
To add comments, please log in or register
Develop trading robots to order. Make profit with Freelance service!
ndbd79
21
ndbd79 2016.06.26 01: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!

ndbd79
21
ndbd79 2016.06.26 05:38  
Please help me!
Carl Schreiber
5959
Carl Schreiber 2016.06.26 07:09  

What is your problem? Errorcode? ..?

Sorry but my crystal ball has a crack. :(

whroeder1
13641
whroeder1 2016.06.26 12: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?
ndbd79
21
ndbd79 2016.06.26 13:13  

Thanks for answer,

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

When I try degug the MT4 close!




whroeder1
13641
whroeder1 2016.06.26 18: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.
ndbd79
21
ndbd79 2016.06.28 07: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!


Fernando Carreiro
1520
Fernando Carreiro 2016.06.28 07: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!

/
To add comments, please log in or register