Questions from Beginners MQL5 MT5 MetaTrader 5 - page 205

 
torblin:
hello all, it doesn't look like the post is for newbies questions oh gee whiz where to ask with dp 200 what advisor will work?
any one practically.
 

Dear Sirs, I ask to have an experienced eye on "attempt number one". The subject is: I have obtained a code by "crossing" a fractal indicator written in MQL5 and azzx_larry-2.0 indicator, the essence of which is to exclude the so called "interior bars" while searching for an extremum (attached). When compiling, we get four errors, all of them are in that part of the code which was borrowed from azzx written in "4". Questions arose when interpreting the "errors":

1. Why is the for statement (place in the code - underlined) proposed to be placed in Global. ('for' - expressions are not allowed on a global scope).


2. Why does the compiler consider High[bar] and Low[bar] (also underlined in the code) undeclared, while several lines above in the code there are High[i] and Low[i] which it does not consider errors.

('High' - undeclared identifier, 'Low' - undeclared identifier).


3. The same goes for limit - why the compiler considers it undeclared. ('limit' - undeclared identifier).

PS: part of the code (fractal indicator) is derived from mql5 documentation, and part of the code from azzx_larry2.0 indicator is derived from mql4 codobase, author azzx


//+------------------------------------------------------------------+
//|                                                     azzx 2.0.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2
#property  indicator_type1   DRAW_ARROW
#property  indicator_type2   DRAW_ARROW
#property  indicator_color1  White
#property  indicator_color2  White
#property  indicator_label1  "azzx Up"
#property  indicator_label2  "azzx Down"
//---- indicator buffers
double max[];
double min[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//---- indicator buffers mapping
   SetIndexBuffer(0,max,INDICATOR_DATA);
   SetIndexBuffer(1,min,INDICATOR_DATA);
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//---- sets first bar from what index will be drawn
   PlotIndexSetInteger(0,PLOT_ARROW,108);
   PlotIndexSetInteger(1,PLOT_ARROW,108);
//---- arrow shifts when drawing
   PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,0);
   PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,0);
//---- sets drawing line empty value--
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);
   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE);
//---- initialization done
  }
//+------------------------------------------------------------------+
//|  Accelerator/Decelerator Oscillator                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,const int prev_calculated,
                const datetime &Time[],
                const double &Open[],
                const double &High[],
                const double &Low[],
                const double &Close[],
                const long &TickVolume[],
                const long &Volume[],
                const int &Spread[])
  {
   int i,limit;
//---
   if(rates_total<3)
      return(0);
//---
   if(prev_calculated<3)
     {
      limit=1;
      //--- clean up arrays
      ArrayInitialize(max,EMPTY_VALUE);
      ArrayInitialize(min,EMPTY_VALUE);
     }
   else limit=rates_total-1;

   for(i=limit;i<rates_total-1 && !IsStopped();i++)
     {
      //---- Up azzx
      if(High[i]>High[i+1] && High[i]>=High[i-1])
         max[i]=High[i];
      else max[i]=EMPTY_VALUE;

      //---- Low azzx
      if(Low[i]<Low[i+1] && Low[i]<=Low[i-1])
         min[i]=Low[i];
      else min[i]=EMPTY_VALUE;
     }
//--- OnCalculate done. Return new prev_calculated.
   return(rates_total);
  }

//+------------------------------------------------------------------+

  // Поиск краткосрочных экстремумов.
  for(i=limit-2;i>1;i--) 
   {
    l = left_bar(i);
    r = right_bar(i);
    
    if((l>0) && (r>0)) 
      {
      if(((Low[l]>=Low[i]) && (Low[r]>Low[i])) ||
         ((Low[l]>Low[i]) && (Low[r]>Low[i]))) 
      {
        min[i] =1;
      }
    }
 
    if((l>0) && (r>0)) 
      {
      if(((High[l]<= High[i]) && (High[r]<High[i])) ||
         ((High[l]<High[i]) && (High[r]<High[i]))) 
      {
        max[i] =1;
      }
    }

  // Отметка экстремумов.
  ArrayInitialize(buf_st_min,0);
  ArrayInitialize(buf_st_max,0);

  
  for(i=limit-1;i>0;i--) 
  {
    switch(min[i]) 
    {
      case 1 : buf_st_min[i]=Low[i]; break;
    }
 
    switch(max[i]) 
    {
      case 1 : buf_st_max[i]=High[i]; break;
    }
  }
  
  return(0);
}
 
// Проверка, что заданный бар - внутренний.
bool is_internal(int bar) 
{
  return((High[bar] < High[bar + 1]) && 
         (Low [bar] > Low [bar + 1]));
}
 
// Возвращает бар слева от заданного бара или -1.
int left_bar(int bar) 
    {
  int i;
  
  for(i=bar+1;i<limit-2;i++) 
{
    if(is_internal(i)==false) 
{
      return(i);
    }
  }
  
  return(-1);
}
 
// Возвращает бар справа от заданного бара или -1.
int right_bar(int bar) {
  int i;
  
  for(i=bar-1;i>0;i--) 
{
    if(is_internal(i)==false) 
{
      return(i);
    }
  }
  
  return(-1);
}
//+------------------------------------------------------------------+
//| Indicator deinitialization function                              |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- почистим график при удалении индикатора
   Comment("");
  }
I think the code has High[i] and Low[i] a few lines above which he doesn't consider to be errors. 3. Similarly about limit - why the compiler considers it undeclared
 

Reshetov:
А робот случаем не из Маркета?
только один.  что там продается - ужас. хотя наверное все они такие
 
beginner_mql:

there are High[i] and Low[i] in the code, which it does not count as errors. 3. The same goes for limit - why the compiler considers it undeclared

You have an early closing curly bracket here:

   return(rates_total);
  }

//+------------------------------------------------------------------+

  // Поиск краткосрочных экстремумов.
  for(i=limit-2;i>1;i--) 

Or several lines are missing, because they are not declared.

    l = left_bar(i);
    r = right_bar(i);
 
vicmos:

You have an early closing curly bracket here:

Or several lines are missing because they are not announced

Thank you for your participation. The bracket has been moved to the end of the code, compilation gave 16 errors - something to work on.

 
Hello all, can you tell forum users who work with ITrade Chaos software product by G. Stanilevich? I like it very much but there are some things I don't understand. If you do not mind, who works or have worked with this product please contact me on Skype. My skype is Furkat1962 Thanks in advance. Sincerely Furkat
 
torblin:
i don't think this post is for beginners so why don't you tell me where to ask a newbie with a 200dpa what advisor will do?
You do not want to understand that FOREX is not a free trade, but it is the same work as any other trade, only the return is higher when you put in the work!
 
I have added an indicator to the chart from the EA - how do I colour this indicator now? The indicator uses 3 lines, I would like to make them all 3 different colours and thickness.
 
YAndrey:
I have added an indicator to the chart from the EA - how do I colour this indicator now? The indicator uses 3 lines, I would like to make them all 3 different colours and thickness.
You can use felt-tip pens on the monitor).
 
zfs:
You can use felt-tip pens on the monitor.)
Yes, you could do that. But I wouldn't like to. And I'd like to hear from smart people ;). I have found a way out by creating a custom indicator with input parameters in the form of colours for each line, but how can I make it simpler? So, again a question. I am creating an iBands indicator in my Expert Advisor. I attach it to the chart. I would like to draw its 3 lines with different colours. Is it possible?