Questions from a "dummy" - page 132

 
Yedelkin:

If you are interested in calculation of data of another indicator, you can do it in the following way. First, we create another indicator with its own method of data calculation, and then we take the handle of this indicator(MQL5 Reference Guide / Technical Indicators / iCustom ) and this handle is used in the new indicator. Look carefully at the example. If you have any questions about the example

I have questions. I still do not understand it.
Ok, let's take Custom Moving Average.mq5 as a base.

add the new smoothing procedure MODE_MYMA to the list - no problem.

the question is how to feed the data. through the i-cast of another indicator? Ok, let's take any indicator made by the second form as an example (if the indicator is made by the first form... i don't know how to take the high-low... so it means only the second form?)

Ok, let's declare

int newHandl;

define it in the onInit (parabolic, i.e. whatever, the main thing is the 2nd type, right? I understand how to implement mine)

newHandl=iCustom(_Symbol,0, "ParabolicSAR.mq5",0.02,0.2);

and then? in onCalculate we feed it instead of the standard price?

CalculateEMA(rates_total,prev_calculated,begin,newHandl);???

does it swear. or what? please explain, I don't understand... (((((

yes, i'm still using mcl4 templates. there, it's simple - loop, data (any!) take, smooth out, output.
But here.... I don't know what to grab onto...

 
GameOver:

(if the indicator is made by the first form... I didn't understand where to take the high-low from... so it means only by the second form?)

Yes, about the high-low it was just an example, how to deal with articles by yourself. For the first form you can take the task of drawing the close[i]/2 line [or sqrt(close[i]/2 )]. In general, you can come up with a bunch of variations using a single array too.

GameOver:

OK, let's declare

int newHandl;

in onInit define it (as an example - parabolic. whatever, the main thing is the 2nd type, right? how to implement your own is roughly clear)

newHandl=iCustom(_Symbol,0, "ParabolicSAR.mq5",0.02,0.2);

That's fine. I will finish it now.

If the indicator handle is correct, it means that we can address to the buffers of this indicator. Look again at the example from MQL5 Reference / Technical Indicators / iCustom There is a line:

//--- скопируем значения индикатора Custom Moving Average в наш индикаторный буфер
   int copy=CopyBuffer(MA_handle,0,0,rates_total,Label1Buffer);

Now read MQL5 Reference / Access to Timeseries and Indicators / CopyBuffer (...Again: many things become clear when parsing examples line by line).

Try to receive data of any indicator buffer, which you have selected. I do not have a terminal, but in parabolic you can see which buffers are calculated and their numbering.

Документация по MQL5: Технические индикаторы
Документация по MQL5: Технические индикаторы
  • www.mql5.com
Технические индикаторы - Документация по MQL5
 

Question about description of ArrayIsSeries() and ArrayGetAsSeries() functions.

There is such a phrase in the Reference Manual:"Arrays passed into the function reflect price data, i.e., these arrays have the timeseries sign and the ArrayIsSeries()function will return true when checking these arrays . But still, in any case, the indexing direction should be checked only with function ArrayGetAsSeries()".

It follows from a literal reading that even if the ArrayIsSeries() function returns true (i.e. confirms that the array being checked is a timeseries array), still the indexing direction should be checked only by ArrayGetAsSeries() function anyway. Then I don't understand the reason for introducing the ArrayIsSeries() function if its results must be additionally checked anyway. What's the point? Is it possible that the array could be a timeseries, but its indexing direction won't be the same as that of a timeseries (the AS_SERIES flag will not be set)?

 


When porting from Mql4 to Mql5 a Lot error has popped up:

'Lot' - constant cannot be modified

input double Lot = 0.1; // Lot

if (MartingaleType ==7)
 {
 if (Counter1==1)
 Lot=Lots() ;
}

How to correct?


 
Dark.Angel:


When porting from Mql4 to Mql5, a Lot error has occurred:

'Lot' - constant cannot be modified

How do you fix it?

You can't. It's not a bug, it's a feature. :)

In mql5 input variables are not modifiable (const).

Make a simple decoupling:

input int x=5;
input double StartLot = 0.01;

int X;
double Lot;
...
...
void OnInit()
  {
   ....
    X=x;
    Lot=StartLot;
   .......
  }
.....
void OnStart()
  {
   ....
   Lot=Lots();
  }
 

In theMQL5 Manual / Array Operations / ArraySetAsSeries section, there is an example when the ArraySetAsSeries() function applies to the const datetime array &time[] on each tick:

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[])
  {
//---  будем хранить время открытия текущего нулевого бара
   static datetime currentBarTimeOpen=0;
//--- перевернем доступ к массиву time[] - сделаем как в таймсерии
   ArraySetAsSeries(time,true);
//--- return value of prev_calculated for next call
   return(rates_total);
  }

Is this what everyone does (flips the array on every tick) to work with the array as a timeseries?

Another question: can arrays used by OnCalculate() arbitrarily change their indexing direction? Or is it enough to check this direction once?

 


When porting from Mql4 to Mql5 an error SymbolInfoDouble:
'SymbolInfoDouble' - no one of the overloads can be applied to the function call

на Mql4:
double a = balance / MarketInfo (Symbol (), MODE_MARGINREQUIRED) - 0.2 ; 

на Mql5:
double a = balance / SymbolInfoDouble(Symbol(), 0) - 0.2 ;

How do I correct it?
 
Dark.Angel:


When porting from Mql4 to Mql5, the SymbolInfoDouble error has appeared:
'SymbolInfoDouble' - no one of the overloads can be applied to the function call


How do I correct it?

Why is there a 0 at the bottom?

https://www.mql5.com/ru/docs/constants/environment_state/marketinfoconstants#enum_symbol_info_double

And in addition to this, check for division by 0.

Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
  • www.mql5.com
Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте - Документация по MQL5
 

The results of the strategy tester are displayed in charts:


Can you tell me where to find out what the different colours on the charts mean?

 
pusheax:

The results of the strategy tester are displayed in charts:

Can you tell me where to find out what the different colours on the charts mean?

The blue ones are profit, the red ones are loss. But the upper left one is only questionable...
Reason: