Questions from Beginners MQL5 MT5 MetaTrader 5 - page 780

 
LookingFor:
   for(bars=start; bars<rates_total; bars++)



Colleagues, please help me

I do not understand what's wrong with the loop, data from the Handle does not go into the array psa1


In OnInit() do the following:

  ArraySetAsSeries(pca1,true);

after that, change your loop accordingly:

   for(bars=start; bars<rates_total; bars++)

Considering that now the rightmost bar of your indicator has index "0".

 

How do I terminate a script by pressing any or a specific key?

 
Vladimir, thank you, is there nothing you can do without changing the indexing?
 
LookingFor:
Vladimir, thank you, is there nothing you can do without changing the indexing?

If you don't want to do anything, then start testing with debugging on historical data. Step by step. See the data from WHERE the bar is copied to.

 
LookingFor:

Colleagues, please help me

I do not understand what's wrong with the loop, data from the Handle does not go into the array psa1


LookingFor:
Vladimir, thanks, but you can't do anything without changing the indexing?

First of all you need to make the code human-readable(Styler - Work with Source Code - Program Development - MetaEditor)

//+------------------------------------------------------------------+ 
//| 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(prev_calculated==0)
     {
      i=bars=start=1;
     }
   else
     {
      start=prev_calculated;
     }
   for(bars=start; bars<rates_total; bars++)
     {
      CopyBuffer(pulse_Handle,0,start,1,pca1);

      if(pca1[bars]!=pca1[bars-1])
        {
         pca2[i]=pca1[bars]; i++;
         string s="";
         s=IntegerToString(pca1[bars])+"  ";
         Print(s); continue;
        }
      else
         continue;
     }
//--- return value of prev_calculated for next call 
   return(rates_total);
  }

you MUST also check - but what was returned by CopyBuffer function? Refer to theCopyBuffer:

Returned value

Number of copied array elements or -1 in case of error.

Further we set breakpoints and run debugging on historical data

run debugging on historical data

and control some variables:

time[rates_total-1]
time[0]
bars
pca1[???]

df

Стилизатор - Работа с исходным кодом - Разработка программ - Справка по MetaEditor
Стилизатор - Работа с исходным кодом - Разработка программ - Справка по MetaEditor
  • www.metatrader5.com
Данная функция предназначена для оформления исходного кода в соответствии с рекомендуемым стандартом. Это позволяет сделать код более читаемым...
 

Help translate to an A

double GetExtremumZZPrice(string symb="0",ENUM_TIMEFRAMES tf=0,int ne=0,int dp=12,int dv=5,int bs=3) {
 if(symb=="0") symb=Symbol();
  double zz;
  int ke=0;
   for(int i=0; i<Bars(symb, tf)-1; i++) {
    zz=iCustom(symb, tf, "ZigZag", dp, dv, bs, 0, i);
    if(zz!=0) {
      ke++;
      if(ke>ne) return(zz);
  }}
  return(0);
 }
 
Vitaly Muzichenko:

Help translate to an A

Read the indicator buffer and in the resulting array look for zz

Документация по MQL5: Доступ к таймсериям и индикаторам / CopyBuffer
Документация по MQL5: Доступ к таймсериям и индикаторам / CopyBuffer
  • www.mql5.com
Доступ к таймсериям и индикаторам / CopyBuffer - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Vitaly Muzichenko:

Help translate to an A

First get the indicator handle! Then use CopyBuffer to get an array of desired values and then loop through them.
 

Thank you all!

Another question: I've looked through the forum and kodobase and I can't find any application for "Trend.mqh", it seems to be all there. If there is a link to the application, please send it here or give me an example by code.

I have found many EAs using Rsi, Ma, Adh and other EAs, but none of them has used SB. Is it so bad, or I have not found the codes, who uses it?


What I need: There is a code, in it I get MA from several timeframes

_ma1 = iMA(Symbol,PERIOD_M15,MAFast,0,MAMethod,MAPrice,i)
_ma2 = iMA(Symbol,PERIOD_M30,MAFast,0,MAMethod,MAPrice,i)
_ma3 = iMA(Symbol,PERIOD_H1, MAFast,0,MAMethod,MAPrice,i)

Not to create several dozen handles in mql5 in OnInit, hopefully SB will solve my problem.

 
Vitaly Muzichenko:

Thank you all!

Another question: I've looked through the forum and kodobase and I can't find any application for "Trend.mqh", it seems that everything is there. If there is a link to the application, please send it here or give me an example by code.

I have found many EAs using Rsi, Ma, Adh and other EAs, but none of them has used SB. Is it so bad, or I have not found the codes, who uses it?


What I need: There is a code, in it I get MA from several timeframes

Not to create several dozens of handles in mql5 in OnInit, I hope SB will solve my problem.


I have to create all of the handles or objects of "Trend.mqh::CiMA" class.

Reason: