Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 872

 
artmedia70:
Calculate virtual line instead of real line.

Already started. The problem is how to flip the indexing of the bars so that the largest index is on the right (to calculate the geometry of the trend line)

Flipped it this way, but how to compare it with an indicator calculation cycle. Maybe there is some other more technical way to reverse the indexation?

for(i=limit;i>=0;i--)
   {
   Bar[i]=Bar[i+1]+1;
   }
 
Forexman77:

Already started. The problem is how to flip the indexing of the bars so that the largest index is on the right (to calculate the geometry of the trend line)

Flipped it this way, but how to compare it with indicator calculation cycle. Maybe there is some other more technical way to flip the indexing?

Why? Use the bar and the price of the two line points to get the price of the bar being calculated:

double EquationDirect(double x1, double y1, double x2, double y2, double x) {return((x2==x1)?y1:(y2-y1)/(x2-x1)*(x-x1)+y1);}

x1 is the bar of the first line point, y1 is the price of the first line point, x2 and y2 are the bar/price of the second line point, x is the number of the bar on which you want the price.

 
artmedia70:

Why? Use the bar and price of the two line points to get the price of the bar to be calculated:

x1 is the bar of the first line point, y1 is the price of the first line point, x2 and y2 are the bar/price of the second line point, x is the number of the bar at which you want the price.

Ok. Thank you.
 
Please advise how to close all positions for the next day at 23.00, no problems during the day (if (Hour_curr>= needed time), but I have a problem with moving after 00.00. Thank you very much.
 
aleks_pavlenko:
Please advise how to close all positions for the next day at 23.00, no problems during the day (if (Hour_curr>= needed time), but I have a problem with moving positions after 00.00. Thanks in advance.
If the day the position is opened is not equal to the day it should be closed.
 
artmedia70:
If the opening day of the position is not equal to the day to close it.
Right, the opening day is not equal to the closing day, how to implement it in mq4.
 

Good afternoon! I don't understand how any part of the code (e.g. description and calculation of global variables) can be made into a include file?

How is the extension mgh assigned to the file?

Does the include file reduce the size of the Expert Advisor?

Thank you.

 
rapid_minus:

Good afternoon! I don't understand how any part of the code (e.g. description and calculation of global variables) can be made into a include file?

How is the extension mgh assigned to the file?

Does the include file reduce the size of the Expert Advisor?

Thank you.

A regular .mq4 can be included, it doesn't have to be .mqh, you don't even need to compile it. The include file differs in the lack of special functions OnInit(), OnDeinit(), OnTick, etc.

There is no effect on the size of the file, whether it is inlined or all code in one piece, the inlined code is included in the final executable code.

 
evillive:

A regular .mq4 file can be included, it doesn't have to be .mqh, you don't even have to compile it. The included file differs in the absence of special functions OnInit(), OnDeinit(), OnTick, etc.

It has no effect on the size of the include file, whether the entire code is included in one piece, the code of the inline is included in the final executable.

Did I get it right: we write a piece of code without functions init(), start() and so on, save it as an .mqh file and that's it? We can put it into terminal_directory\experts\include and it will be called and executed without any problems?

Thank you.

 
rapid_minus:

Did I get it right - we write a piece of code without init(), start() and other functions, save it as an .mqh file and that's it? We can put it into terminal_directory\experts\include and it will be called and executed without any problems?

Thank you.

We simply write functions in the .mqh file, connect this file to the Expert Advisor #include <file_name.mqh> if in the directory include, or #include "file_name.mqh" if in the folder with the main program (Expert Advisor, indicator, script). That is all. The functions that are in the file will be visible in the Expert Advisor/indicator/script. The main thing is to connect the file before calling any function from the Expert Advisor/indicator/script that is in the file.
Reason: