[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 332

 
Lonely_man:
I have a template (with indices) and 3 terminals. On one terminal, when I apply a template to EURGBP Daily terminal hangs forever - on other symbols, or other times, or other terminals of the same DC all works without problems, but on one terminal and one symbol one time hangs.

Imagine that one of the indicators is so sharpened that the D1 timeframe is a scary place for it. :) In short, you need to look at the code - most likely the cause is there.
 
drknn:

Imagine if some of the indicators are so sharpened that the D1 timeframe is a scary place for them. :) In short, you need to look at the code - most likely the cause is there.
I got confused by the fact that everything works on other terminals. I've just found the bug - the quote for 1970 in the area of GBP 14000.
 

Must have messed up something with the buffers again. Please take a look at it.

The task is as follows:

1) The LSMA is calculated. If [i]>[i+1] - colour is green, if [i]<[i+1] - colour is red. Everything is clear with this.

2) I need to find the length of the series of green and red values and store them in an array. This is the problem which I have not yet managed to solve by myself.

//+------------------------------------------------------------------+
//|                                                   LSMA_Stat2.mq4 |
//|                                                       silhouette |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "silhouette"
#property link      "http://www.metaquotes.net"

#property copyright "silhouette"
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Green
#property indicator_color3 Red
//+------------------------------------------------------------------+
double BufferYellow[],BufferGreen[], BufferRed[];
int GreenSeries[], RedSeries[], g=0, r=0, gc=0, rc=0;
string Symb;

int init()
  {
   Symb=Symbol();
   
   SetIndexBuffer(0,BufferYellow);
   SetIndexBuffer(1,BufferGreen);
   SetIndexBuffer(2,BufferRed);
   
   SetIndexStyle(0,DRAW_LINE,EMPTY,2);
   SetIndexStyle(1,DRAW_LINE,EMPTY,2);
   SetIndexStyle(2,DRAW_LINE,EMPTY,2);  
   return(0);
  }

int deinit()
  {

   return(0);
  }

int start()
  {
   double tmp1, tmp2, LSMA;
   
   int counted_bars=IndicatorCounted();
   int limit=Bars-counted_bars-1;
   if (limit>1) 
      limit=Bars-1;
      
   for(int i=limit; i>0; i--)
    {
     tmp1=iMA(Symb,Period(),34,0,MODE_SMA,0,i);
     tmp2=iMA(Symb,Period(),34,0,MODE_LWMA,0,i);
     LSMA=3.0*tmp2-2.0*tmp1;
      
     BufferYellow[i]=LSMA;
     BufferGreen[i]=LSMA;
     BufferRed[i]=LSMA;

     if(BufferYellow[i]>BufferYellow[i+1])
      {
       BufferRed[i]=EMPTY_VALUE;
      }
     else if(BufferYellow[i]<BufferYellow[i+1])
      {
       BufferGreen[i]=EMPTY_VALUE;
      }
     else
      {
       BufferRed[i]=EMPTY_VALUE;
       BufferGreen[i]=EMPTY_VALUE;
      }                        
      
     if(BufferGreen[i]!=EMPTY_VALUE && BufferRed[i]==EMPTY_VALUE)
      {
       g++;
      }
     if(BufferGreen[i]==EMPTY_VALUE && BufferRed[i]!=EMPTY_VALUE)
      {
       r++;
      }
     if(BufferGreen[i]==EMPTY_VALUE && BufferRed[i]==EMPTY_VALUE)
      {
       if(BufferGreen[i+1]!=EMPTY_VALUE)
        {
         GreenSeries[gc]=g;
         gc++;
         g=0;
        }
       if(BufferRed[i+1]!=EMPTY_VALUE)
        {
         RedSeries[rc]=r;
         rc++;
         r=0;
        }
      }              
    }
   return(0);
  }
 
silhouette:

I must have messed up something with the buffers again. Please take a look at it.

The task is as follows:

1) The LSMA is calculated. If [i]>[i+1] - colour is green, if [i]<[i+1] - colour is red. Everything is clear with this.

2) I need to find the length of the series of green and red values and store them in an array. This is the problem which I have not yet managed to solve by myself.


What's not to like about this indicator
 
Vinin:

Why don't you like this indicator?

Vinin, I actually did it according to your sample, but the point is different: it's not the calculation method itself that's important to me (be it the simplest MA), but the solution to the problem in point 2.

I need to get an array that stores the length of green or red series for further analysis.

 
Please advise. There are 2 virtual balance graphs (for sell and buy orders) in real life they may diverge a lot. How can I translate them into any relative units to be able to time the moment of crossing of these graphs.
 
silhouette:

Vinin, I actually did it according to your sample, but the point is different: it's not the calculation method itself that matters to me (be it the simplest MA), but the solution to the problem in point 2.

I need to get an array, which stores the length of green or red series for further analysis.


Why do you need an array?
 
Vinin:

Why do you need an array?
For subsequent statistical analysis. In Excel, for example.
 

There is a library for mouse trading https://www.mql5.com/ru/code/9671

I'm having absolutely no luck connecting it, please help.

I download all the files I need into the expert folder then compile, but still the indicators have black windows with no data.

Obviously some kind of childish error, but I can't find it for 24 hours.


 
TheXpert:

There is no need to folder anything. The archive already contains all the files, all you need to do is unpack the archive into the terminal folder and compile.

Only indicator files are compiled, libraries (mqh) don't need to be compiled. Try to put a new terminal and practice on it.