Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 638

 
Alexey Viktorov:

So limit it to the middle. Who forbids it?

If he is not male, then apparently PMS syndrome forbids reading and asking adequate questions, so far only squealing let me... I really want it this way and not that way...

ZS: I'm on 4 forums, if possible, I do about 20 free MT4 jobs a month, and about 10 orders for individual TK, but regularly every 1.5-2 months a fairy tale character appears who'll blow my mind because he doesn't need to understand MT4 or do a specific task under the order ... He just needs to make someone's head spin, that's his job...

I would give Artem a monument in his lifetime for his patience in dealing with such characters in such a long time.

 
Alexey Viktorov:

It's very easy to do.

Option 1 is to use your brain.

If you can't do it, you can use option 2.

Without fussing and without insulting the developers and forum users in particular, ask for help on the forum.

Otherwise you will be sent to the . mail.

I know how to get around this "feature".

Unlike the "respectable people" of this forum I will not make a secret out of it.

This way looks like this:

If you fill the remainder of the array we are not interested in with the maximum value, then the indicators stop drawing lines.

This is exactly the "idiotic" solution of this problem we see in standard MT4 indicators (for example, SMA, EMA, SMMA and others).

But, you must agree, this is complete idiocy. And I suspect that precisely because of this idiocy there is not a single word about this way of "solving" this problem in the description.

Maybe I'm wrong, but I haven't found any other way in the standard indicators.

 
Alexey Viktorov:

Exactly like this. You open a new account and transfer money from the old account to the new account by internal transfer with absolutely no fees.

I don't get it at all. Alexey, how do you even know what you are talking about? What does it have to do with 8 indicator buffers that some translator can't translate? I don't know...
 
Igor Makanu:

If he is not male, then apparently PMS syndrome forbids reading and asking adequate questions, so far only squealing let me... I really want it this way and not that way...

ZS: I'm on 4 forums, if possible, I do about 20 free MT4 jobs a month, and about 10 orders for individual TK, but regularly every 1.5-2 months a fairy tale character appears who'll blow my mind because he doesn't need to understand MT4 or do a specific task under the order ... He just needs to make someone's head spin, that's his job...

I would give Artem a monument in his lifetime for his patience in dealing with such characters in such a long time.

You probably need a rest.

 
You have to do children soberly so that there are no problems in the future.
 

What am I doing wrong?

//+------------------------------------------------------------------+
//|                                                      CCI_DIV.mq5 |
//|                                                        RomanRott |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "RomanRott"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot HL_CCI
#property indicator_label1  "HL_CCI"
#property indicator_type1   DRAW_HISTOGRAM
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- input parameters
input int      Period_=70; //Период
//--- indicator buffers
double         HL_CCIBuffer[];
int cci_h1, cci_h2;
double cci1[], cci2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,HL_CCIBuffer,INDICATOR_DATA);
   cci_h1 = iCCI(_Symbol, PERIOD_CURRENT, Period_, PRICE_HIGH);
   cci_h2 = iCCI(_Symbol, PERIOD_CURRENT, Period_, PRICE_LOW);
   
   //ArraySetAsSeries(cci1, true);
   //ArraySetAsSeries(cci2, true);
//---
   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[])
  {
   CopyBuffer(cci_h1, 0, 0, rates_total-prev_calculated, cci1);
   CopyBuffer(cci_h2, 0, 0, rates_total-prev_calculated, cci2);
   for(int i = prev_calculated; i<rates_total;i++){
      HL_CCIBuffer[i] = cci1[i]-cci2[i];
   }
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Artyom Trishkin:
I don't understand anything at all. Alexei, how do you even know what we're talking about? What does it have to do with 8 indicator buffers that some translator can't translate? It's hard to understand...

Artyom, you're a programmer... M. Botvinnik once said that a computer is an idiot. Hence, every programmer knows how to talk to an idiot.

I've already read about 8 or 512 buffers before, and this text was about the complaint about the broker refusing to migrate the account from MT4 to MT5.


Igor Makanu:

I would give a monument to Artem in his lifetime for his patience in dealing with such characters.

I already have...


 
Roman Sharanov:

What am I doing wrong?

//+------------------------------------------------------------------+
//|                                                      CCI_DIV.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                             https://mql5.com/ru/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://mql5.com/ru/users/artmedia70"
#property version   "1.00"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_plots   1
//--- plot DivCCI
#property indicator_label1  "DivCCI"
#property indicator_type1   DRAW_HISTOGRAM
#property indicator_color1  C'143,188,139'
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
//--- input parameters
input uint     InpPeriod=70;   // CCI period
//--- indicator buffers
double         BufferDivCCI[];
double         BufferHCCI[];
double         BufferLCCI[];
//--- global variables
int            period_cci;
int            handle_hcci;
int            handle_lcci;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- set global variables
   period_cci=int(InpPeriod<2 ? 2 : InpPeriod);
//--- indicator buffers mapping
   SetIndexBuffer(0,BufferDivCCI,INDICATOR_DATA);
   SetIndexBuffer(1,BufferHCCI,INDICATOR_CALCULATIONS);
   SetIndexBuffer(2,BufferLCCI,INDICATOR_CALCULATIONS);
//--- setting indicator parameters
   IndicatorSetString(INDICATOR_SHORTNAME,"HL CCI ("+(string)period_cci+")");
   IndicatorSetInteger(INDICATOR_DIGITS,Digits());
//--- setting buffer arrays as timeseries
   ArraySetAsSeries(BufferDivCCI,true);
   ArraySetAsSeries(BufferHCCI,true);
   ArraySetAsSeries(BufferLCCI,true);
//--- create CCI's handles
   ResetLastError();
   handle_hcci=iCCI(NULL,PERIOD_CURRENT,period_cci,PRICE_HIGH);
   if(handle_hcci==INVALID_HANDLE)
     {
      Print("The iCCI(",(string)period_cci,") object was not created: Error ",GetLastError());
      return INIT_FAILED;
     }
   handle_lcci=iCCI(NULL,PERIOD_CURRENT,period_cci,PRICE_LOW);
   if(handle_lcci==INVALID_HANDLE)
     {
      Print("The iCCI(",(string)period_cci,") object was not created: Error ",GetLastError());
      return INIT_FAILED;
     }
//---
   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[])
  {
//--- Проверка и расчёт количества просчитываемых баров
   if(rates_total<fmax(period_cci,4)) return 0;
//--- Проверка и расчёт количества просчитываемых баров
   int limit=rates_total-prev_calculated;
   if(limit>1)
     {
      limit=rates_total-1;
      ArrayInitialize(BufferDivCCI,EMPTY_VALUE);
      ArrayInitialize(BufferHCCI,0);
      ArrayInitialize(BufferLCCI,0);
     }
//--- Подготовка данных
   int count=(limit>1 ? rates_total : 1),copied=0;
   copied=CopyBuffer(handle_hcci,0,0,count,BufferHCCI);
   if(copied!=count) return 0;
   copied=CopyBuffer(handle_lcci,0,0,count,BufferLCCI);
   if(copied!=count) return 0;

//--- Расчёт индикатора
   for(int i=limit; i>=0 && !IsStopped(); i--)
     {
      BufferDivCCI[i]=BufferHCCI[i]-BufferLCCI[i];
     }

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 

advise what should be added to the court so that the indicator works every second instead of every tick?

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 Red

#property strict

double buffer[];

void init()

{

SetIndexBuffer(0,buffer);

SetIndexStyle(0,STYLE_SOLID);

}

void start ()

{


double vbid_1 = MarketInfo("USDRUB",MODE_BID);

double vbid_2 = MarketInfo("EURUSD",MODE_BID);




double a = vbid_1;

double b = vbid_2;

double x = a / b ;

buffer[0] = x;

Comment (x);

}


 
gonsharov:

What do I need to add to the court to make the indicator work every second instead of every tick?

You need to readhttps://docs.mql4.com/ru/basis/function/events

and write your event handlerOnTimer()

Функции обработки событий - Функции - Основы языка - Справочник MQL4
Функции обработки событий - Функции - Основы языка - Справочник MQL4
  • docs.mql4.com
В языке MQL4 предусмотрена обработка некоторых предопределенных событий. Функции для обработки этих событий должны быть определены в программе MQL4: имя функции, тип возвращаемого значения, состав параметров (если они есть) и их типы должны строго соответствовать описанию функции-обработчика события. Именно по типу возвращаемого значения и по...