Questions from Beginners MQL5 MT5 MetaTrader 5 - page 467

 
Honestly, I don't understand how to use the library normally in the terminal without searching and sorting capabilities... Just stupidly scrolling through hundreds of lines?!!!
 
Alena000:
To be honest, I don't understand how to use the library in the terminal without searching and sorting at all... Just stupidly scroll through hundreds of lines?!!!

The search is built into the MetaEditor (top right corner). You can search for occurrences by:

  • open document
  • through all files
  • MQL4/MQL5.community
Search is built into the terminal itself (top right corner). From the terminal, you can search the entire MQL5.community (Articles, Products, Library, Signals, Forum, Blogs, Documentation).

 
anyone have any thoughts on the question? ))
 
Maxim Dobrovolskii:
anyone have any thoughts on the question? ))

Might help.

Files:
Fractal.mq4  4 kb
 
Victor Nikolaev:

Might help.

I would like to understand and find out why my variant is not working. I think it's the Expert Advisor+indicator combination that's the problem.
 
Maxim Dobrovolskii:
I would like to understand and find out why my variant does not work. I think it is because of the Expert Advisor+indicator combination and I don't know what exactly it is about.
Maybe, the matter is that in OnTick() you read only the zero buffer, but in OnDeinit() you read both zero and the first one?
 
Maxim Dobrovolskii:
Thank you, but I want to understand and find out why my version does not work. I think it is because of the Expert Advisor+indicator combination.

Do you want me to prove that there is not much of a problem.

Just need the code of the indicator. I don't like to copy it.

Maybe I will change something in your indicator (and I even know what).

 
Alexey Viktorov:
Maybe the problem is that in OnTick() you read only zero buffer, but in OnDeinit() both zero and first buffer?
The Deinit is to show that there is a value in one of the buffers.
 
Victor Nikolaev:

Do you want me to prove that there is not much of a problem.

Just need the code of the indicator. I don't like to copy it.

Maybe I will change something in your indicator (and I even know what).

//+------------------------------------------------------------------+
//|                                               modify_Fractal.mq4 |
//|          MoneyRobotics Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "MoneyRobotics Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property  indicator_label1  "Up"
#property  indicator_label2  "Down"
#property  indicator_type1   DRAW_ARROW
#property  indicator_type2   DRAW_ARROW
#property  indicator_style1  STYLE_SOLID
#property  indicator_style2  STYLE_SOLID
#property  indicator_width1  1
#property  indicator_width2  1
#property  indicator_color1 Red
#property  indicator_color2 Blue


//--- indicator buffers

double ExtUpFractalsBuffer[];
double ExtDownFractalsBuffer[];

//+-----------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//---- indicator buffers mapping  
    SetIndexBuffer(0,ExtUpFractalsBuffer);
    SetIndexBuffer(1,ExtDownFractalsBuffer);  
//---- drawing settings
    SetIndexStyle(0,DRAW_ARROW);
    SetIndexArrow(0,217);
    SetIndexStyle(1,DRAW_ARROW);
    SetIndexArrow(1,218);
//----
    SetIndexEmptyValue(0,0.0);
    SetIndexEmptyValue(1,0.0);
//---- name for DataWindow
    SetIndexLabel(0,"Modify_Fractal Up");
    SetIndexLabel(1,"Modify_Fractal Down");
//---- initialization done  
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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 &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int    i, nCountedBars;
   double dCurrent;
   nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted    
   
   if(nCountedBars<=8) i=Bars-nCountedBars-4;
   if(nCountedBars>8)
     {
      nCountedBars--;
      i=Bars-nCountedBars-4;
     }
//----Up and Down Fractals
   while ( i >= 4 )
     {
      //----Fractals up bFound=false;
      dCurrent=High[i];
      if(dCurrent>High[i+1] && dCurrent>High[i+2] && dCurrent>High[i+3] &&
         dCurrent>High[i-1] && dCurrent>High[i-2] && dCurrent>High[i-3] && 
         dCurrent>High[i-4] )
        {
         ExtUpFractalsBuffer[i]=NormalizeDouble(dCurrent + 1* Point,Digits);
        }
                           
      //----Fractals down
      dCurrent=Low[i];
      if(dCurrent<Low[i+1] && dCurrent<Low[i+2] && dCurrent<Low[i+3] && 
         dCurrent<Low[i-1] && dCurrent<Low[i-2] && dCurrent<Low[i-3] && 
         dCurrent<Low[i-4])
        {
         ExtDownFractalsBuffer[i]=NormalizeDouble(dCurrent - 1* Point,Digits);
        }
      i--;
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+


The code of indicator.
 
Maxim Dobrovolskii:
Deinit is to show that there is a value in one buffer.

There is value in both zero and first buffer. On M15 we have fractals on 5 and 21 bars now. This script

/********************Script program start function*******************/
void OnStart()
{
Print("******************", iCustom(_Symbol, PERIOD_CURRENT, "modify_Fractal", 1, 5));
Print("******************", iCustom(_Symbol, PERIOD_CURRENT, "modify_Fractal", 0, 21));
}/*******************************************************************/

finds and prints everything correctly. Correspondingly, the Expert Advisor will find iCustom() working equally in the script and in the Expert Advisor.

Reason: