Errors, bugs, questions - page 3156

 

Good afternoon!

Please help me with a little code:

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<3) return(0);
   
 int Start;
 
 if(prev_calculated<5)
  {
   Start=2;
   ArrayInitialize(Max1,EMPTY_VALUE);
   ArrayInitialize(Min1,EMPTY_VALUE);
  }
 
 else Start=rates_total-2;
   
//-- 1-й главный цикл --
  for(int i=Start;i<rates_total-1 && !IsStopped();i++)
    {
     if(high[i]>high[i+1] && low[i]>low[i+1])
      { 
       Max1[i]=high[i];
       Min1[i]=low[i];
      }
else if (high[i]<high[i+1] && low[i]<low[i+1])
      { 
       Max1[i]=high[i];
       Min1[i]=low[i];
      }
      else 
         {
          Max1[i]=EMPTY_VALUE;
          Min1[i]=EMPTY_VALUE;
         }

    }
 return(rates_total);
}

It requires a given bar to be compared to the previous bar, but it's the other way around and compares it to zero.

 
Sergey Gubar #:

Good afternoon!

Please help me with a little code:

I need this bar to be compared to the previous bar, but it's the opposite, it's compared to zero.

Please attach a screenshot (preferably against a white background) and show WHO is the "current bar" and who is the "previous bar". This is important.

 
Attached is a screenshot
 
Sergey Gubar #:
Attached is a screenshot

There is a mistake here.

You have not flipped the arrays in OnCalculate, which means that their indexing is such that the rightmost bar on the chart has the index [rates_total-1], respectively the bar to its left will have the index [rates_total-1-1].

 
Vladimir Karputov #:

There is a mistake here.

You have not flipped the arrays in OnCalculate, which means that their indexing is such that the rightmost bar on the chart has the index [rates_total-1], respectively the bar to its left will have the index [rates_total-1-1].

Thank you very much for the insights, now everything is in its place.
 
Vladimir Karputov #:

There is a mistake here.

The arrays in OnCalculate are not flipped, so their indexing is such that the rightmost bar in the chart has the index [rates_total-1], respectively the bar to its left will have the index [rates_total-1-1].

I was looking at this picture (picture in attached file).

How do you insert the picture? It doesn't work for me.

 
Sergey Gubar #:

I was looking at this picture (picture in the attached file).

How do you insert the picture? I can't get it to work.

If there is no such button it means that your rating is not high enough. Right now it's 11.

 
Artyom Trishkin #:

If there is no button, the rating is still too low. Your rating is now 11.

Got it, thanks.
 

The multicurrency EA on mql5 managed to buy the rouble at 0.86 and took a profit. And in visual mode, but not in normal mode

I suspect that it is not the quotes, but the deal on NZDCAD

DP      0       02:25:32.172    Trade   2021.12.13 01:44:38   market buy 0.01 USDRUB, close #26 (0.86458 / 0.86480 / 0.86458)
FQ      0       02:25:32.172    Trades  2021.12.13 01:44:38   deal #228  buy 0.01 NZDCAD at 0.86480 done (based on order #228)
 EO      0       02:25:32.172    Trade   2021.12.13 01:44:38   deal performed [#228  buy 0.01 NZDCAD at 0.86480]
LH      0       02:25:32.172    Trade   2021.12.13 01:44:38   order performed buy 0.01 at 0.86480 [#228  buy 0.01 USDRUB at 0.86480]
GD      0       02:25:32.174    _job_ (15) (AUDCAD,M5)  2021.12.13 01:44:38   CTrade::OrderSend: market buy 0.01 position #26  USDRUB [done at 0.865]
 
Sofiia Butenko #:

The multicurrency EA on mql5 managed to buy the ruble at 0.86 and took a profit. And in visual mode, but not in normal mode

I suspect that it is not because of quotes but because of a deal on NZDCAD

Hi all, could you please tell me why the custom indicators do not open in the terminal after the update on Jan. 28 and later?