Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 895

 
lil_lil:

Not really, although it will come in handy for the test. I want the indicator to be attached to the online chart after the EA is attached to it. Is it possible?

I haven't tried it. Theoretically, it's unlikely to work. Maybe that's the reason why I haven't tried it yet. It will look like this: each time the EA is loaded, the template will be applied, on which the EA is launched again. And everything repeats, the template is applied, a new copy of the EA is launched and so on.

It might be better, if you want it so badly that your teeth ache, to make a script that applies the template with the EA and indicators.

 
Thank you all for your participation. I'll try to call ChartApplyTemplate() in the global terminal and assign a variable value, but before calling ChartApplyTemplate() I'll check its value.
 

Hi,

How can I create bars using 30 ticks of each PERIOD_M1?

I want to create a new character for my analysis.

 
Hello! Please help me solve a problem, I'm having trouble. I need to prescribe in the code of the EA, working on the active chart of the symbol 1, to draw horizontal lines in another, NOT active chart of the symbol 2. It means that the chart of symbol 2 is open on the screen. For example, for the second SUI30 symbol I did this:
double SUop0 = iOpen("SUI30",PERIOD_H1,0);
double lp = SUop0-67;
double hp = SUop0+67; 

   Fun_New_Bar();
      if(New_Bar)      
         {
   ObjectCreate("SUI30","lineForBuy",OBJ_HLINE,0,0,lp);
   ObjectCreate("SUI30","lineForSell",OBJ_HLINE,0,0,hp);
         }
but the meta-editor gives a message implicit conversion from 'string' to 'number'. What am I doing wrong, and how do I solve it? Thank you.

 
novichok2018:
Hello! Please help me solve a problem, I can't do it. In the code of the Expert Advisor, which works on the active chart of the symbol 1, I need to prescribe the drawing of horizontal lines in another, NOT active chart of the symbol 2. It means that the chart of symbol 2 is open on the screen. For example, for the second SUI30 symbol, I did this: but the meta-editor gives a message implicit conversion from 'string' to 'number'. What am I doing wrong, and how do I solve it? Thank you.

We need to use another function overload

bool  ObjectCreate( 
   long          chart_id,      // идентификатор графика 
   string        object_name,   // имя объекта 
   ENUM_OBJECT   object_type,   // тип объекта 
   int           sub_window,    // индекс окна 
   datetime      time1,         // время первой точки привязки 
   double        price1,        // цена первой точки привязки 
   ... 
   datetime      timeN=0,       // время N-точки привязки 
   double        priceN=0       // цена N-точки привязки 
   );

And this chart identifier should be found by trying to enumerate charts from ChartFirst();

long  ChartNext( 
   long  chart_id      // идентификатор графика
   );

Example from documentation

//--- переменные для идентификаторов графиков 
   long currChart,prevChart=ChartFirst(); 
   int i=0,limit=100; 
   Print("ChartFirst = ",ChartSymbol(prevChart)," ID = ",prevChart); 
   while(i<limit)// у нас наверняка не больше 100 открытых графиков 
     { 
      currChart=ChartNext(prevChart); // на основании предыдущего получим новый график 
      if(currChart<0) break;          // достигли конца списка графиков 
      Print(i,ChartSymbol(currChart)," ID =",currChart); 
      prevChart=currChart;// запомним идентификатор текущего графика для ChartNext() 
      i++;// не забудем увеличить счетчик 
     }
 
Alexey Viktorov:

We need to use a different function overload

Thanks, I'm trying to figure it out.

 
Alexey Viktorov:

We need to use another function overload

And this chart identifier should be found by trying to enumerate charts from ChartFirst();

An example from the documentation

Unfortunately, my attempts to make it out did not lead to anything. I simply added errors related toChartNext() to the existing messages. I don't understand the point.

 
novichok2018:

Unfortunately for me, trying to figure it out didn't lead to anything. Just added errors related to ChartNext() application to the existing messages. I don't understand the point.

Well, you can use a constant chart ID to make it easier. Write a script

Print(ChartID());

Run it on the chart on which you want to draw these lines. Then write this value into the function as the chart ID.

And on the good side, the example from the documentation, it is not a ready-made function, like take it and use it. It is necessary to check the symbol and period in the loop. If the right one is found, then exit the loop and use the obtained identifier.

 

there is a constant in the OPENCL cl_ inline and it is equal to #define CL_DBL_MAX 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0 by double-checking the degree of two in 1024 got. 2^1024 = 179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216 And then below that is the number of pi

after

#define CL_M_PI 3.141592653589893115998

3.141592653589793238462643383279502884197169

explain why ????

 
Alexey Viktorov:

Well, you can use a constant graph ID to make the task easier. Write a script

Run it on the chart on which you want to draw these lines. Then write this value into the function as the graph ID.

And on the good side, the example from the documentation is not a ready-made function, just take it and use it. It is necessary in the loop to check the symbol and period. If the right one is found, then exit the loop and use the obtained identifier.

Thank you. Everything worked with the script, it draws the lines.

Reason: