Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1240

 
How to increase the number of optimisable parameters in the tester? Maybe there are some virtual ways in MQL, maybe in Python or somewhere else ? Give me some direction, please...
 
Vladimir M.:
How to increase the number of optimized parameters in the tester? Maybe there are some virtual ways in MQL, maybe in Python or somewhere else ? Give me some pointers, please...

OnTester()

 
Vladimir Karputov:

Take an example from the reference! How many times? Don't use your own made-up constructs if you don't understand much of their meaning. Use standard constructs - figure out how they work. After that, throw your own constructs in the trash.


And use 'MQL Wizard' to generate a template.

Code

and result


Vladimir, I have the feeling they're trying to talk between a mute and a deaf person.

  1. I used 'MQL Wizard' template.
  2. Why are you bothering with my constructions? They're not worse than yours, especially for my needs!

if(rates_total - prev_calculated > 1)

When I run the indicator rates_total = ХХХ (let's say ХХХ = 1000), prev_calculated = 0, rates_total - prev_calculated (1000 - 0 = 1000) greater than 1! The condition worked!

Next

if(prev_calculated == 0)

When you start the indicator, prev_calculated = 0. The condition worked!

And then explain me how yours differs

      Buffer1[i]=open[i];
      Buffer2[i]=high[i];
      Buffer3[i]=low[i];
      Buffer4[i]=close[i];

from mine

            barsBuffer1[0] = newCandles_Open[i];
            barsBuffer2[0] = newCandles_High[i];
            barsBuffer3[0] = newCandles_Low[i];
            barsBuffer4[0] = newCandles_Close[i];

considering myArraySetAsSeries is set to true ???

Why yours candlesticks are rendered, but mine are not?

I've been asking you to explain it to me for almost 2 weeks now! No need to send me to read documentation! I know it almost by heart. Just tell me WHY? Either explain, or tell me you don't know, or tell me you don't want to answer!

Oh shit, have you forgotten the title of this thread?

 
Сергей Таболин:


How about this? You have all indexes assigned to a zero index in the buffers.

            barsBuffer1[i] = newCandles_Open[i];
            barsBuffer2[i] = newCandles_High[i];
            barsBuffer3[i] = newCandles_Low[i];
            barsBuffer4[i] = newCandles_Close[i];
 
Сергей Таболин:


That's what I'm trying to teach you: I keep giving you examples, but you keep banging your head against the wall.

For the last time: throw your designs in the trash and use the standard ones. Then you can ask: how to draw (for example, the five rightmost candlesticks on the chart) according to your rules. But not before you trash your constructs, not before you stop using prefixincrement instead ofpostfix increment...

 
Сергей Таболин:


Example

//+------------------------------------------------------------------+
//|                                                 Draw Candles.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_plots   1
//--- plot USDJPY
#property indicator_label1  "USDJPY"
#property indicator_type1   DRAW_CANDLES
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- input parameters
input int      Input1=9;
//--- indicator buffers
double   Buffer1[];
double   Buffer2[];
double   Buffer3[];
double   Buffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Buffer1,INDICATOR_DATA);
   SetIndexBuffer(1,Buffer2,INDICATOR_DATA);
   SetIndexBuffer(2,Buffer3,INDICATOR_DATA);
   SetIndexBuffer(3,Buffer4,INDICATOR_DATA);
//--- the 0 (empty) value will mot participate in drawing
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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(rates_total<10)
      return(0);
//---
   int limit=prev_calculated-5;
   if(prev_calculated==0)
     {
      limit=rates_total-5;
      for(int j=0; j<limit; j++)
        {
         Buffer1[j]=0.0;
         Buffer2[j]=0.0;
         Buffer3[j]=0.0;
         Buffer4[j]=0.0;
        }
     }
   for(int i=limit; i<rates_total; i++)
     {
      if(i<rates_total-5)
        {
         //--- затираем всё, что левее пяти свеч (сюда попадаем при рождении нового бара)
         Buffer1[i]=0.0;
         Buffer2[i]=0.0;
         Buffer3[i]=0.0;
         Buffer4[i]=0.0;
         continue;
        }
      //--- четыре левые свечи будут перерисовываться на каждом тике - это не оптимально,
      //--- но пригодится в будущем (если для них потом подсовывать тики)
      //--- пятая свеча (она же самая правая на графике) реагирует онлайн на изменение текущих цен
      Buffer1[i]=open[i];
      Buffer2[i]=high[i];
      Buffer3[i]=low[i];
      Buffer4[i]=close[i];
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Result:


Files:
 
Vladimir Karputov:

That's what I'm trying to teach you: I keep giving you examples, but you keep banging your head against the wall.

For the last time: throw your designs in the trash and use the standard ones. Then you can ask: how to draw (for example, the five rightmost candlesticks on the chart) according to your rules. But not before you throw away your constructs, not before you stop using prefixincrement instead ofpostfix increment...

What do you have against it? Because you don't understand it? I often use this loop, for example

for(int i PositionsTotal(); i-- > 0)

and there's no problem at all.........

 
Alexey Viktorov:

What is it that you don't like about him? Because you don't understand it? I, for example, often use this cycle

for(int i PositionsTotal(); i-- > 0)

and there's no problem at all.........

How about trying to read it instead of rushing to respond? You use (like most) postfix. And your example is postfixed. You shouldn't rush just to answer instead of thinking.

 
Youri Lazurenko:
CPU load 100% and after a few minutes of work the computer crashes (processor phenom II x4 955 (4 cores, 3.2 GHz), the cooler is to spare). After two times I decided not to risk any more. How should this be interpreted?

Check your computer with Aida64 or Linx - if there are no problems with CPU and memory tests and the temperature is within normal limits, then check the HDD. Generally it looks like the power supply, if it has not been changed for a long time, it is likely to be the problem. The terminal works fine on the second phenoms.

 
Good afternoon colleagues, do you know if there is such a symbol in the form of a horizontal dash in one ball, I can't find it :-(
Reason: