[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 51

 
vikon писал(а) >>

I know about opening an order using code.

I need to create a semi-automatic system with management properties.

I open a position manually, but the EA monitors the lot size and changes it by default in MT (service/settings/trading/default volume).

Is it possible to do this?

No. At least not in MQL4

 
granit77 >> :

Reference would be helpful:

double iWPR( string symbol, int timeframe, int period, int shift)

Hence, correct is:

THANKS A LOT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 
People, how do you pull the formation time of a particular column in MACD without using a price chart?
 
Noterday >> :
People, how do you pull the formation time of a particular bar in MACD without using the price chart?

The column corresponds to the time of the bar formation on the price chart,

That is, you need to know the number of a particular bar.

 

What are the rules for code optimisation? I am interested in the rules for writing, not the algorithm.

To be more precise, let me give you an example:

there are two "identical" scripts:

int start()
  {
//----
  int start=GetTickCount();
  int Massiv[100000000];
  int x=ArraySize( Massiv);
  for (int a=0; a<= x; a++)
    {
    Massiv[ a]= a;
    }
  Alert("прошло времени: ",GetTickCount()- start);
//----
   return(0);
  }

и

int start()
  {
//----
  int start=GetTickCount();
  int Massiv[100000000];
  for (int a=0; a<=ArraySize( Massiv); a++)
    {
    Massiv[ a]= a;
    }
  Alert("прошло времени: ",GetTickCount()- start);
//----
   return(0);
  }

the first is twice as fast as the second. (for me it is 4 seconds)

It's clear that arrays of a hundred million are not often used :-) and in reality the gain is a couple of milliseconds for an ordinary array and that the main problem is in buggy algorithms and not in such trifles, but nevertheless...

 
beruk >> :

What are the rules for code optimisation? I am interested in the rules for writing, not the algorithm.

To be more precise, let me give you an example:

there are two "identical" scripts:

и

the first is twice as fast as the second. (for me it is 4 seconds)

It's clear that arrays of a hundred million are not often used :-) and in reality the gain will be a couple of milliseconds for an ordinary array and that the main problem is in buggy algorithms and not in such tiny details, but still...

There are no rules as such. That is, you can write it as you see fit and it will work. Of course, it will work with different efficiency.

For each operation its cost in terms of time expression is known - you can find it in the language standards, as well as the workflow of loops and other language constructs (the C standard - I mention it because I doubt that you tried to understand it, starting from the basics - the producer recommended to consult this very language standard in all unspecified cases).

In the second case you constantly call the ArraySize(Massiv) function - this is the most expensive operation (function call - any, not this one), while the comparison operation is called in each loop.

In this case: the loop

for (int a=ArraySize(Massiv)-1;a>0;a--)

will do the same thing but significantly faster. I mean the way the loop is organized. If you have voluminous calculations in a loop, there will be no great difference.

There's one "but" - if you're using a tester or retrained networks - the difference will be very significant and will appear very, very ....

Yes, one more thing: you have an error in the first script - going beyond the array boundaries. Read the manuals - it's all written there. You should write it like this:

int x=ArraySize(Massiv);
for (int a=0;a<x;a++)

Good luck.

 

Good afternoon

Please explain how to interpret this passage in the FileOpen tutorial

===

The contents of the entries in the files

With any combination of modes, data records are written to the file without gaps. When files are formed in FILE_BIN mode, data records are written consecutively. Depending on the type of data written to the file (and the recording functions used for this purpose), a combination of end-of-line characters ("\r\n") may be written between groups of records. When files are generated in FILE_CSV mode, data records are separated with a file delimiter (usually ';'), and groups of records (consisting of strings) are separated with a combination of end-of-line characters ("\r\n").

===

everything is clearwith "int FileOpen(string filename, int mode, int delimiter=';') "

Where should I put ("\r\n") ? Can it be used with FILE_CSV ? Give me an example with ("\r\n") please, I'm so dumb.

 
Hello! I need to write an Expert Advisor for this: https://www.mql5.com/ru/code/8663 indicator, I mean HP.mq4 (if it goes up buy, if it goes down sell). It does overdraw, but in case of large periods e.g. 100-200 it is bearable. Or you can add a signal MA if the signal is below this indicator - buy, if higher - sell.
 
teetrinker >> :

Good afternoon

Please explain how to interpret this passage in the FileOpen tutorial

===

The contents of the entries in the files

With any combination of modes, data records are written to the file without gaps. When files are formed in FILE_BIN mode, data records are written consecutively. Depending on the type of data written to the file (and the recording functions used for this purpose), a combination of end-of-line characters ("\r\n") may be written between groups of records. When files are generated in FILE_CSV mode, data records are separated with a file delimiter (usually ';'), and groups of records (consisting of strings) are separated with a combination of end-of-line characters ("\r\n").

===

everything is clearwith "int FileOpen(string filename, int mode, int delimiter=';')".

but where should "\r\n" be used? Can it be used with FILE_CSV?

Nowhere. The manual says in clear Russian: "groups of records (making strings) are separated with a combination of line-end characters ("\r\n")".

 

Could you give me a hint?

in my EA, several alerts are in a row in one block, and several in a row in another block

in the log in the test they are not in order but sorted - 2 alerts from the first block, 3 from the second, then 3 from the first and the last 2 from the second

put a 500 sec slip after each one, i.e. half a second and no action - all are still random and in 1 sec can be placed all 10

what is the reason?

how to make the alerts go in order?

Reason: