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

 
Vitaly Muzichenko:

It is dimensionless as it is, but it is two-dimensional, and you can put a dimensionless number of elements in two dimensions.

What are you doing anyway, do you have any idea what the result of the work you do should be? Or are you making logic up as you go along?

In the current example, I want to be able to place an infinite number of orders with any lot in order to avoid exceeding the specified limits.

Of course, we know the limits, but I would like to do it that way.

I proceed from the fact that if you specify an element in brackets, it will be the last one

So I got this kind of crap. I was expecting an order by order... lot? I want the result (lot of such an order *coefficient) to be added to the order instead of the lot

and the question of retrieving data from there

I want to get the following result as I see it

MyArray[0][0.01]

MyArray[1][0.01]

MyArray[2][0.02]

etc...


void CalcOrders()

{

int CountOrders=0;

double MyArray [99][99];

for(i=OrdersTotal()-1; i>=0; i--)

     {

      if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) && (OrderSymbol()==Symbol())

         && (OrderMagicNumber()==Magic) && (OrderType()==OP_SELL))

         CountOrders++;

         ArrayResize(MyArray,CountOrders+1);

         MyArray[CountOrders][0]=OrderLots();

         Print("MyArray[CountOrders][0]",MyArray[CountOrders][0]);

     }

}    

2017.01.13 12:51:14.372 2017.01.05 16:30:00  martin GBPUSD,M5: MyArray[CountOrders][0]0.02
2017.01.13 12:51:14.372 2017.01.05 16:25:00  martin GBPUSD,M5: MyArray[CountOrders][0]0.01
2017.01.13 12:51:14.372 2017.01.05 16:25:00  martin GBPUSD,M5: MyArray[CountOrders][0]0.02
2017.01.13 12:51:14.371 2017.01.05 16:20:00  martin GBPUSD,M5: MyArray[CountOrders][0]0.01
2017.01.13 12:51:14.371 2017.01.05 16:20:00  martin GBPUSD,M5: MyArray[CountOrders][0]0.02
2017.01.13 12:51:14.371 2017.01.05 16:15:00  martin GBPUSD,M5: MyArray[CountOrders][0]0.01

 
trader781:

In the current example, I want to be able to place an infinite number of orders with any lots in order not to exceed its limits.

Of course, we all know the limits, but I want to do it this way

I proceed from the fact that if you specify an element in brackets, it will be the last one

So I got this kind of crap. I was expecting an order by order... lot? I want the result(lot of such an order *coefficient) to be added to the order instead of the lot

And the question of retrieving data from there



void CalcOrders()

{

int CountOrders=0;

double MyArray [99][99];

for(i=OrdersTotal()-1; i>=0; i--)

     {

      if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) && (OrderSymbol()==Symbol())

         && (OrderMagicNumber()==Magic) && (OrderType()==OP_SELL))

         CountOrders++;

         ArrayResize(MyArray,CountOrders+1);

         MyArray[CountOrders][0]=OrderLots();

         Print("MyArray[CountOrders][0]",MyArray[CountOrders][0]);

     }

}    

2017.01.13 12:51:14.372 2017.01.05 16:30:00  martin GBPUSD,M5: MyArray[CountOrders][0]0.02
2017.01.13 12:51:14.372 2017.01.05 16:25:00  martin GBPUSD,M5: MyArray[CountOrders][0]0.01
2017.01.13 12:51:14.372 2017.01.05 16:25:00  martin GBPUSD,M5: MyArray[CountOrders][0]0.02
2017.01.13 12:51:14.371 2017.01.05 16:20:00  martin GBPUSD,M5: MyArray[CountOrders][0]0.01
2017.01.13 12:51:14.371 2017.01.05 16:20:00  martin GBPUSD,M5: MyArray[CountOrders][0]0.02
2017.01.13 12:51:14.371 2017.01.05 16:15:00  martin GBPUSD,M5: MyArray[CountOrders][0]0.01


Explain what you need.

Let's store everything in an array, then what?

Then we'll rotate the array and look for the position you need, what?

Lot what position, is there a definition, or by eye, I looked at the tab Trade, yes need 6, right?
 
Alekseu Fedotov:

Can you please explain what you need?

Let's put everything into an array, then what?

We'll rotate the array, look for the position you need, what?

I look at the "Trade" tab, I know I need 6, right?

OnTick()

if the condition for opening a position is correct

{open position}

if the position opening condition is correct

{fill the same amount }

If the last lot is position 2 - let's add lot *1.5 (the function find the last will return the second) and this will be the third

if this is the fourth order

top up {lot zero+lot one}

if it will be the fifth order

fill {lot 1 position +lot 3}

There is currently a definition of the last position in the list

We need to write it into an array and get the right one out at once because I cannot see any other way of implementation at the moment so the number of orders and positions should theoretically be infinite

I have shown you what I have done in the function, I don't know if it is correct or not.

I need to pull the data out and know in advance which order may be opened in my account

I do not pretend that the system is working, the implementation is important

 
Good time. Can you advise if you want to test an EA and it uses commands to write and read bits and csv file, as we know there are errors in the test mode to use operations with these files
 
Top2n:
Good afternoon. Can you advise if I need to test an EA and it uses commands for writing and reading bits and csv file, as we know errors occur in test mode when using file operations.

No errors occur. Only writes to a different folder if the flag is not used

FILE_COMMON

4096

Location of file in shared folder of all client terminals \Terminal\Common\Files. This flag is used when opening files (FileOpen()), copying files (FileCopy(), FileMove()) and verifying the existence of files (FileIsExist())

 
Alexey Viktorov:

No error occurs. Only writes to a different folder if the flag is not used

FILE_COMMON

4096

Location of file in shared folder of all client terminals \Terminal\Common\Files. This flag is used when opening files (FileOpen()), copying files (FileCopy(), FileMove()) and verifying the existence of files (FileIsExist())

Well, I use FileOpen()

input string InpFileName="data.bin";
input string InpDirectoryName="";
string path=InpDirectoryName+"//"+InpFileName;

C:\Users\Rassvet\AppData\Roaming\MetaQuotes\Terminal\36A64B8C79A6163D85E6173B54096685\MQL5\Files

5004:ERR_FILE_CANNOT_OPEN = Open File Error

 
Top2n:

Well, I'm using FileOpen()

input string InpFileName="data.bin";
input string InpDirectoryName="";
string path=InpDirectoryName+"//"+ InpFileName;

C:\Users\Rassvet\AppData\Roaming\MetaQuotes\Terminal\36A64B8C79A6163D85E6173B54096685\MQL5\Files

5004:ERR_FILE_CANNOT_OPEN = File Open Error

FileOpen() is not a flag... The flag is FILE_COMMON.

If you don't want to write to a separate folder, you don't have to specify it as an empty string in the path. Unnecessary is highlighted in yellow.


 
Alexey Viktorov:

FileOpen() is not a flag... The flag is FILE_COMMON.

If you don't want to write to a separate folder, you don't have to specify it as an empty string in the path. Unnecessary is highlighted in yellow.


There is a contact thank you
 
Hello!
Can you tell me where I can read about the #property strict property ?
 
Leo59:
Hello!
Can you tell me where I can read about the #property strict property?
For example here https://docs.mql4.com/ru/basis/preprosessor/compilation
Свойства программ (#property) - Препроцессор - Основы языка - Справочник MQL4
Свойства программ (#property) - Препроцессор - Основы языка - Справочник MQL4
  • docs.mql4.com
Свойства программ (#property) - Препроцессор - Основы языка - Справочник MQL4
Reason: