Questions from Beginners MQL5 MT5 MetaTrader 5 - page 66

 
mario065:

Hi,

Of course not.

If there's more than one turkey, you have to do as many pairs for each one as it eats.

One handler to use all pairs.

Use a handle one by one, i.e. copy the indicator buffers and then assign the value of the next indicator to the handle.

But I don't understand why you need to save on handles when they are elementary integers and have almost no effect on resources?

 
Reshetov:

Use the handles one by one, i.e. copy the indicator buffers and then assign the value of the next indicator to the handle.

But I don't understand why you need to save on handles when they are elementary integers and have practically no effect on resources?

Hi there.

Last year I wrote an external function like this:

void CalculatePairs(string dSymbol) {

   atrHandle1=iATR(dSymbol, TimeFrame1, ATRPeriod);
   atrHandle2=iATR(dSymbol, TimeFrame5, ATRPeriod);
   atrHandle3=iATR(dSymbol, TimeFrame15, ATRPeriod);
   atrHandle4=iATR(dSymbol, TimeFrame30, ATRPeriod);
   atrHandle5=iATR(dSymbol, TimeFrame60, ATRPeriod);
   muvHandle1=iMA(dSymbol,TimeFrame1,MAPeriod,0,MAMethod,InpPr);
   muvHandle2=iMA(dSymbol,TimeFrame5,MAPeriod,0,MAMethod,InpPr);
   muvHandle3=iMA(dSymbol,TimeFrame15,MAPeriod,0,MAMethod,InpPr);
   muvHandle4=iMA(dSymbol,TimeFrame30,MAPeriod,0,MAMethod,InpPr);
   muvHandle5=iMA(dSymbol,TimeFrame60,MAPeriod,0,MAMethod,InpPr);
   if(atrHandle1<0 || atrHandle2<0 || atrHandle3<0 || atrHandle4<0 || atrHandle5<0 ||
   muvHandle1<0 || muvHandle2<0 || muvHandle3<0 || muvHandle4<0 || muvHandle5<0 )
     {
      Alert("Error Creating Handles for indicators - error: ",GetLastError(),"!!");
     }

   double ma1[],ma2[],ma3[],ma4[],ma5[];
   double atr1[],atr2[],atr3[],atr4[],atr5[];

   ArraySetAsSeries(ma1, true);ArraySetAsSeries(ma2, true);ArraySetAsSeries(ma3, true);
   ArraySetAsSeries(ma4, true);ArraySetAsSeries(ma5, true);
   ArraySetAsSeries(atr1, true);ArraySetAsSeries(atr2, true);ArraySetAsSeries(atr3, true);
   ArraySetAsSeries(atr4, true);ArraySetAsSeries(atr5, true);

   if (NormalizeDouble(CopyBuffer(muvHandle1,0,0,1,ma1),4) < 0){Print("CopyBuffermuvHandle error =",GetLastError());}
   if (NormalizeDouble(CopyBuffer(muvHandle2,0,0,1,ma2),4) < 0){Print("CopyBuffermuvHandle error =",GetLastError());}
   if (NormalizeDouble(CopyBuffer(muvHandle3,0,0,1,ma3),4) < 0){Print("CopyBuffermuvHandle error =",GetLastError());}
   if (NormalizeDouble(CopyBuffer(muvHandle4,0,0,1,ma4),4) < 0){Print("CopyBuffermuvHandle error =",GetLastError());}
   if (NormalizeDouble(CopyBuffer(muvHandle5,0,0,1,ma5),4) < 0){Print("CopyBuffermuvHandle error =",GetLastError());}
   if (NormalizeDouble(CopyBuffer(atrHandle1,0,0,1,atr1),4) < 0){Print("CopyBufferatrHandle error =",GetLastError());}
   if (NormalizeDouble(CopyBuffer(atrHandle2,0,0,1,atr2),4) < 0){Print("CopyBufferatrHandle error =",GetLastError());}
   if (NormalizeDouble(CopyBuffer(atrHandle3,0,0,1,atr3),4) < 0){Print("CopyBufferatrHandle error =",GetLastError());}
   if (NormalizeDouble(CopyBuffer(atrHandle4,0,0,1,atr4),4) < 0){Print("CopyBufferatrHandle error =",GetLastError());}
   if (NormalizeDouble(CopyBuffer(atrHandle5,0,0,1,atr5),4) < 0){Print("CopyBufferatrHandle error =",GetLastError());}

   Result = 0;
}
double FGroup(){
      CalculatePairs(Currency1);{
         Pair1 = Result;}

Of course, until it made calculations it gave error 4806, but then it works fine.

Today I opened this code and wondered if there is another way.

An error is an error.

How many Handles should I get for 8 pairs and 5 timeframes?

This is not a question for resources, I have to do something better.

Документация по MQL5: Основы языка / Функции / Описание внешних функций
Документация по MQL5: Основы языка / Функции / Описание внешних функций
  • www.mql5.com
Основы языка / Функции / Описание внешних функций - Документация по MQL5
 
mario065:

Hi there.

Last year I wrote an external function like this:

Of course, until it did the calculations, it gave error 4806, but then it works fine.

I opened this code today and wondered if there is another way.

  1. A way of what?
  2. Why do I need CalculatePairs() function if it does not show anything but errors?

Remove this very function from your code and sleep well.

 
Reshetov:
  1. The way of what?
  2. Why do you need the CalculatePairs() function if it produces nothing but errors?

Remove this very function from your code and sleep well.

There are some "great" calculations that are not shown.

Then other functions take the selected pair and do something again.

The method is simple.

For example:

We make a handle of the indicator, it has no symbol, timeframe.

When we create a CopyBuffer, we indicate the timeframe and pair.

For example:

int OnInit()

It looks like this: Handle = indicator name

void OnTick()

It would look like this: CopyBuffer(specified symbol, timeframe, where from we copy it, how much we copy it, where we copy it)

This is just a dialogue :) with you.

 
mario065:

There are some "great" calculations that haven't been shown.

I see. You have ArraySetSeries() applied to arrays without data, i.e. before information is loaded into them, while you need it after copying buffers.
 
Reshetov:
I see. You have ArraySetSeries() applied to arrays without data, i.e. before information has been loaded into them, while we need it after copying buffers.

Exactly.

But I think it will be easier for everyone if it is done in CopyBuffer - i.e. you specify which pair and frame.

The indicator itself makes the same calculation, if only it specifies which pair and frame.

If the architecture of MT5 itself allows easier to do it.

Good idea :) .

 
Reshetov:
I see. You have ArraySetSeries() applied to arrays without data, i.e. before information has been loaded into them, while you want it after copying buffers.
No difference.
 
i have kind of configured everything, signed everything, made settings in the terminal, but i do not want to trade automatically. when i try to place a pending order, it installs and writes to me about synchronization and delete all orders in the terminal, and then i see orders from the supplier. what do i need to do?
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 
Yedelkin:

If the Expert Advisor uses MFI, then its code must contain a line with getting the handle of this indicator:"MQL5 Reference / Technical Indicators / iMFI ". Accordingly, getting a handle on the moving average indicator is described here:"MQL5 Reference Guide / Technical Indicators / iMA ".

Try also to read the article"Indicator by indicator in MQL5".

I have read the article. However, it did not answer my question "How can I remove iMA handles located in MFI indicator window and registering bar close price?".

The iMA handle you mentioned does not apply to the iMA located in the indicator window. Description by the standard method the advisor removes the iMA handle from the chart.
 
Leser: Read the article. However, it did not answer my question "How do I remove the handles of the iMA located in the MFI indicator window and registering the bar closing price?"

You originally outlined the problem as follows: "The Expert Advisor uses MFI; Ma is not on the chart (window #1), but in the window with the MFI indicator (window #2)". I replied:"If your Expert Advisor uses MFI, then its code must contain a line with getting handle of this indicator: "MQL5 Reference Guide / Technical Indicators / iMFI" .

Therefore, I suggest to begin with figuring out how exactly your Expert Advisor gets indicator handle from "window #2". And we will think out something there.

Leser : I have read the article. However, it does not answer my question ". iMA located in the window of MFI indicator and registering the bar closing price".
A clarifying question: on what data do you build the MA indicator: on the values of the MFI indicator or on bar closing prices? Nothing has been said before about "registering bar closing prices". That's why I provided a link to the article "Indicator from Indicator".
Reason: