Download MetaTrader 5
To add comments, please log in or register
Post web links to other trader's signals and make profit
songxiaohui
10
songxiaohui 2015.10.26 06:09 

 This is my program code,l always don't know why there is a number -9500000 and my customer indicator don't generate. 

 

#property copyright "Albert Einstein"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot truevolume
#property indicator_label1  "truevolume"
#property indicator_type1   DRAW_HISTOGRAM
#property indicator_color1  clrDarkTurquoise
#property indicator_style1  STYLE_SOLID
#property indicator_width1  3
#property indicator_minimum 0
//--- indicator buffers
double         truevolumeBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
{
   SetIndexBuffer(0,truevolumeBuffer);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   
   return 0;
 }
 
 
 int start()
 {
   int count=IndicatorCounted();
   int index=Bars-count-1;
   
   while(index>=0)
 {
   
    double x1=Close[index]-Low[index];
    double x2=High[index]-Low[index];
   
   double ratio=x1/x2;
   
   truevolumeBuffer[index]=(Volume[index])*ratio;
   
   index--;
 }
 
 return 0;
 
 }   
Carl Schreiber
5932
Carl Schreiber 2015.10.26 07:46  

As indicators don't really work if started by the debugger, copy your idea into a script and go through your code line by line.

But even correctly compiled scripts causes repeating problems in the debugger: You'll find:

2015.10.26 10:36:49.576 cannot open file 'C:\..\MQL4\Scripts\test_script02.ex4' [2]

Just save the script with File => Save As.. under the same name!

BTW do you know the default value of indicator buffers and how to set it: SetIndexEmptyValue()?

songxiaohui
10
songxiaohui 2015.10.26 10:12  
gooly:

As indicators don't really work if started by the debugger, copy your idea into a script and go through your code line by line.

But even correctly compiled scripts causes repeating problems in the debugger: You'll find:

Just save the script with File => Save As.. under the same name!

BTW do you know the default value of indicator buffers and how to set it: SetIndexEmptyValue()?


When I  delete the line "double ratio=x1/x2;" and "*ratio",the client terminal will generate the graph normally.

But when I  add the "double ratio=x1/x2;" back,the graph in the seperate window disappear and there is -950000 on the vertical axis.

Carl Schreiber
5932
Carl Schreiber 2015.10.26 10:30  
you might have a zero divide check x2 to be != 0!
songxiaohui
10
songxiaohui 2015.10.26 10:43  
gooly:
you might have a zero divide check x2 to be != 0!
The problem has beed solved. Thank you!
/
To add comments, please log in or register