Questions from Beginners MQL5 MT5 MetaTrader 5 - page 236

 
barabashkakvn:
All calculations are done in OnCalculate (i.e. a new bar event is defined here)
Thank you, I'll have a look. Maybe I do not understand something, but it seems that in Five it is not possible to specify the buffer index for getting the value of custom indicator.
 
forexman77:
Thanks, I'll have a look. Maybe I don't understand something, but it seems that there is no possibility to specify the buffer index to get the value of custom indicator.
iCustom gives the handle of the custom indicator. Then CopyBuffer, in which the second parameter is the buffer number.
 
Can you tell me if there is a function that stops the optimisation of an EA completely, rather than a separate optimisation run?
 
barabashkakvn:
iCustom gives the handle of the custom indicator. Then CopyBuffer, in which the second parameter is the buffer number.

Tell me, is it possible to get the value of an indicator in the script?

I tried it this way:

input int MA_Period=21;
input int MA_Shift=0;
input ENUM_MA_METHOD MA_Method=MODE_SMA;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
double MA_handle=iCustom(NULL,0,"Examples\\Custom Moving Average",
                     MA_Period,
                     MA_Shift,
                     MA_Method,
                     PRICE_CLOSE // считаем по ценам закрытия
                     );  
Alert("MA_handle=",MA_handle);
  }

I get the value on any indicator 10.

I tried it this way too (the error 4807 comes out):

input int MA_Period=21;
input int MA_Shift=0;
input ENUM_MA_METHOD MA_Method=MODE_SMA;
int MA_handle;
double ma1Val[]; 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {

//--- массив значений индикатора MA
   ArraySetAsSeries(ma1Val,true);
//--- копируем значения индикаторов из индикаторных буферов
   if(CopyBuffer(MA_handle,0,0,3,ma1Val)<0)
     {
      Alert("Ошибка копирования буферов индикатора Moving Average - номер ошибки:",GetLastError(),"!!");
      return;
     }
MA_handle=iCustom(NULL,0,"Examples\\Custom Moving Average",
                     MA_Period,
                     MA_Shift,
                     MA_Method,
                     PRICE_CLOSE // считаем по ценам закрытия
                     );  
Alert("ma1Val[0]=",ma1Val[0]);
  }
 
forexman77:
The following procedure will be used:
iCustom gives you the handle of the custom indicator. Then you CopyBuffer, in which the second parameter is the buffer number.

Tell me, is it possible to get the value of an indicator in the script?

I tried it this way:

I get the value on any indicator 10.

Tried another way (error 4807 comes out):

1.Read the iCustom help.
2. To get indicator buffer value: get indicator handle, then copy the required indicator buffer using CopyBuffer.
 
barabashkakvn:
1.Read the iCustom help.
2. Order of obtaining indicator buffer value: obtain indicator handle, and then use CopyBuffer to copy the required indicator buffer by this handle.
I understand, I will study it. I asked about the script because it doesn't have "OnInit" and it gets the handle. So the script asks for the handle before "OnStart"?
 
forexman77:
I see, I'll look into it. I asked about the script because it doesn't have "OnInit" and it gets the handle. Does this mean that the script requests the handle before "OnStart"?
OnInit is present in Expert Advisors and indicators.
 
barabashkakvn:
OnInit is in experts and indicators.
It all worked!!! Thank you!!!
 
forexman77:
It all worked out! Thank you!!!
You're welcome.
 
Fleder:
Products in the Market have between 5 and 20 activations (at the discretion of the retailer). If you haven't used up your activation attempts, don't worry, they won't charge you extra money.
Thanks for the reply, I will press the button to buy. There is no other :-)
Reason: