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

 
Алексей Барбашин:

void OnTick() { int period = 15; int timeis = returntick(period, 1).curtime; Print("timeis= ", TimeToStr(timeis,TIME_SECONDS)); This is where I try to destroy the pointer }


It's not quite clear what exactly can be destroyed here. No wonder that memory leaks. What is a pointer? A pointer is a reference to the memory address where the created dynamic variable is stored. In fact, you call the procedure of getting a pointer to the class variable, in this procedure the class object is created, placed in memory, then the pointer is returned to the function of getting the ticks and.... is destroyed when you exit the function. Note that the pointer is destroyed, but the memory is not cleared! And with each new tick more and more memory is eaten up! To avoid this point in your code, you should first of all remove the abbreviation and place the pointer into another variable:TickReturn* temptick =returntick(period, 1);// get the pointer and place it into a variable int timeis = temptick.curtime; // Get the required value from the object by the pointer ...... delete temptick; // Destroy the pointer and clear the memory

And before destroying the pointer, it's better to check if it's correct to avoid the delete error.

On the whole, I wouldn't bother with the pointers and the class in particular, as the task is much easier in fact and there's no need to use the class. Create a structure with necessary fields, declare a global variable with type of this structure, make a function to update information in this structure at every tick and use it to collect what you need, because the variable will be global, you won't need to use it in functions and you won't need pointers.


Thanks, I remembered why I switched to shorthand, the variable isn't updated in loops (obviously function isn't called) and I need to make a new one for each sneeze, and then kill it. Anyway, it's easier to switch returntick to switch.

 
Vitaly Muzichenko:

Send a post-request to the server with the account number

On the server, check the incoming number against all lines in the CSV file, and if there is a match, then from this line in the file send a response to the terminal. All that remains is to read the response from the server in the terminal and display it on the chart.

In general, it's easier to implement such things on MySQL than on file.


Thanks for the reply, Vitaly!

I am trying to understand it for three days, but nothing comes out (I am a beginner - at the beginning of my career)...

Can you describe it in more detail? With any example...

Sorry for my lack of understanding...

 

And one more question...

I wanted the Beam to draw a line from the current price - to the end of the day to the end of the level (23:59) (white2), but it draws to the end of the day (as required), but not at the level (white2), and goes deep down to the border chart.

And I give it any of the levels (red1, red2, etc.), but it still rays up or down to infinity. Did I write it correctly to always start Beam fromHigh[0], i.e. with a new candlestick it shifts to a new candlestick (i.e. follows the price) or it draws Beam only once? The levels are getting from CSV. Please help...

if(уровни==Daily)
        {
         double red1 = d_input[0];
         double red2 = d_input[1];
         double blue1 = d_input[2];
         double blue2 = d_input[3];
         double white = d_input[4];
         double signal= d_input[5];
         double z_1 = d_input[6];
         double z_2 = d_input[7];
         double white2 = d_input[8];
                 
         t0 = дата_уровней + 1*PeriodSeconds(PERIOD_M1);
         t1 = дата_уровней + 24*PeriodSeconds(PERIOD_H1);

         Draw_Level("red1", red1, c_day_1, STYLE_SOLID, 2);  
         Draw_Level("red2", red2, c_day_1, STYLE_SOLID, 2);  
         Draw_Level("blue1", blue1, c_day_2, STYLE_SOLID, 2);  
         Draw_Level("blue2", blue2, c_day_2, STYLE_SOLID, 2);  
         Draw_Level("white", white,c_day_3, STYLE_SOLID,2);
         Draw_Level("white2", white2,c_day_3, STYLE_DOT,0);
        
         Draw_Level("green1",z_1, c_day_4, STYLE_SOLID,2);
         Draw_Level("green2",z_2,c_day_3, STYLE_DOT,2);
               
        string name = "Ray";
         int window = 0, time1 = (int)Time[0], time2 = (int)StrToTime(txt_data+" 23:59");
          double price1 = High[0], price2= white2;
         
          ObjectCreate(name, OBJ_TREND, window, time1, price1, time2, price2);
          ObjectSet(name, OBJPROP_COLOR, clrAqua);
          ObjectSet(name, OBJPROP_RAY_RIGHT, false);
          ObjectSet(name,OBJPROP_WIDTH,1);
          ObjectSet(name,OBJPROP_STYLE,2);
              
        
        if(показ_не отработанных)
            if(!check_white_level(дата_уровней,white))
               draw_line(t0,white,c_day_3);
                 else(Draw_Level("white", white,c_day_3, STYLE_SOLID,1));// меняет толщину белой при достижении ценой
                
        }
 
MosheDayan:

And one more question...

I wanted the Beam to draw a line from the current price - to the end of the day to the end of the level (23:59) (white2), but it draws to the end of the day (as required), but not at the level (white2), and goes deep down to the border chart.

And I tuck it to any of the levels (red1, red2, etc.), but it still rays up or down to infinity. Levels get from CSV. Help plz...

Find out (check it out ) the value of white2 with Alert or Print.
 
STARIJ:
Check the value of white2 using Alert or Print.
Alert immediately writes "EURUSD ErrorFileOpen() for write" and all levels of the current day disappear... Yesterday's levels and all previous ones are still there... So... The beam starts where it should and goes to the level of yesterday's white2, but not at the end of the day, and today vertically downwards it visually stops at the level of yesterday's white2.
 
MosheDayan:
I checked using Alert and immediately wrote "EURUSD Error FileOpen() for writing" and all levels of the current day disappear... Yesterday's levels and all previous ones stay... So... The beam on the spot starts where it should and goes to the level of yesterday's white2, but not at the end of the day, and today vertically downwards one can visually see that it stops at the level of yesterday's white2.

Why do you need to access the file? You have the value white2 and output it with Alert("white2 = ", white2) before using it;

 
STARIJ:

Why do you need to refer to the file? You have the value of white2 and output it with Alert("white2 = ", white2) before using it;

Thanks for the clarification.... Here's what it says: white2 = 0.0

p.s. I'm the one who's stupid... White2 = 0.0 is for other currency pairs that do not have levels in CSV. But there are levels for EURUSD in CSV and Alert shows them yesterday (white2 1.1720) and today (white2 1.1810).

The ray starts where it should, but it goes to the level of yesterday's white2 at 1.1720, instead of today's white2 at 1.1810 and it does not go to the end of the day 23:59, but today it stops at yesterday's white2, i.e. 1.1720.

 

something incomprehensible

described a function

int IsBelow

//>>>>>>>>>>>>>>>>>>>>>

{

Alert("beg IsBelow");

Alert("NextTick=",NextTick);

//---------------------------


//---------------------------

Alert("NextTick=",NextTick);

Alert("end IsBelow");

}

//>>>>>>>>>>>>>>>>>>>>>>>

got a message before the semicolon expexted body {

Question which semicolon is expected ?

Please explain ...

 
buyanov:

something incomprehensible

described a function

int IsBelow

//>>>>>>>>>>>>>>>>>>>>>

{

Alert("beg IsBelow");

Alert("NextTick=",NextTick);

//---------------------------


//---------------------------

Alert("NextTick=",NextTick);

Alert("end IsBelow");

}

//>>>>>>>>>>>>>>>>>>>>>>>

got a message before the semicolon expexted body {

Question which semicolon is expected ?

Please explain...


void IsBelow()

 
buyanov:

something incomprehensible

described a function

int IsBelow

//>>>>>>>>>>>>>>>>>>>>>

{

Alert("beg IsBelow");

Alert("NextTick=",NextTick);

//---------------------------


//---------------------------

Alert("NextTick=",NextTick);

Alert("end IsBelow");

}

//>>>>>>>>>>>>>>>>>>>>>>>

got a message before the semicolon expexted body {

Question which semicolon is expected ?

Please explain ...

The answer is here
Функции - Основы языка - Справочник MQL4
Функции - Основы языка - Справочник MQL4
  • docs.mql4.com
Функции - Основы языка - Справочник MQL4
Reason: