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

 
Maxim Kuznetsov:

When opening an order, write the number of the rule/variable to it in the comment.

Then when you do a history check, you pull that number, add 1 to it and get a new rule number

Thank you! That's a good way. I'll try

 
Igor Makanu:

Experiment with this code, maybe this is what you need

2019.11.28 22:31:26.409 tst EURUSD,H1: 0.7 ---> 0.7

2019.11.28 22:31:26.409 tst EURUSD,H1: 0.6 ---> 0.7

2019.11.28 22:31:26.409 tst EURUSD,H1: 0.5 ---> 0.6

2019.11.28 22:31:26.409 tst EURUSD,H1: 0.4 ---> 0.5

2019.11.28 22:31:26.409 tst EURUSD,H1: 0.3 ---> 0.4

2019.11.28 22:31:26.409 tst EURUSD,H1: 0.2 ---> 0.3

2019.11.28 22:31:26.409 tst EURUSD,H1: 0.1 ---> 0.2

In my function GetNextLot() you feed the volume of the last closed order, and it will return the next value of the Lot_XX setting

the only limitation in this code is that you have to configure lots in ascending order - I think the code is simple and straightforward, you can modify it to suit your needs

Thanks!!!

 
Corvin85:

Thank you!!!

please

If your lot calculation is arbitrary, you could try replacing if with switch-case in my example

 
I want to open two MT4 terminals and connect to one EA from them, i.e. one program will be installed in one terminal and the other will also be able to find the EA, it is very hard to compile the program and every time to throw a file there and there. Is it possible to do this?
 

What is the best way to write the algorithm?


Task:

One Expert Advisor runs on different charts.

I need to have a separate file with minute by minute information about account, balance, equity, etc.


Now it turns out that all Expert Advisors write all information in one file. As a result, we have a lot of unnecessary entries.


What could be the ingenious solution for only one bot to make records in the file? (And if for example it was deleted, the records started to make another bot, etc.)

 
Seric29:
I want to open 2 terminals MT4 and connect to one EA from them, ie one program will be installed in one terminal and the second will also be able to find the EA, it is very hard to compile a program and every time I have to throw a file there and there. Is it possible to do this?

You can't do that.

Look for a Windows program that synchronises data in folders. And set it up so that the EA is automatically copied to the new terminal

 
Sergey Likho:

What is the best way to write the algorithm?


Task:

One Expert Advisor runs on different charts.

I need to have a separate file with minute by minute information about account, balance, equity, etc.


Now it turns out that all Expert Advisors write all information in one file. As a result, we have a lot of unnecessary entries.


What is the possible original solution, so that only one bot writes to the file (And, for example, if it was deleted, the other bot starts making records, etc.).

You can try to organize communication through GV.

For example: Started the first one, it doesn't find GV and creates it with a certain name. The chart ID can be used as the value. You start the next Expert Advisor, GV is there, it does not write. You delete the first one, it checks the value and if the value is equal to the chart ID, it deletes the GV. The next one sees that the GV is absent and creates it with its own value.

Thus GV can be deleted only by the one who created it or by the one who is in charge, literally. Deletes it by hand.

 

Hello, everyone. I have a silly question, I just don't want to experiment a bit. I have an indicator, I don't need to output anything from it, but my Expert Advisor has to take data from it. What is the right way to initialize arrays?

INDICATOR_DATA or INDICATOR_CALCULATIONS?

Well, in general, I want to know, if I can get data from the buffer number in the iCustom function - using the buffer defined as SetIndexBuffer(N, BufferName, INDICATOR_CALCULATIONS);

 
Никита Парамонов:

Hello, everyone. I have a silly question, I just don't want to experiment a bit. I have an indicator, I don't need to output anything from it, but my Expert Advisor has to take data from it. What is the right way to initialize arrays?

INDICATOR_DATA or INDICATOR_CALCULATIONS?

Well, in general, I want to know, if I can get data from the buffer number in the iCustom function - using the buffer defined as SetIndexBuffer(N, BufferName, INDICATOR_CALCULATIONS);

Take the standard MA, change the buffer data type, compile and check in the terminal data window (Ctrl+D)

 

ChartID() is written to the terminal's global variables with an error. what is this nonsense?


Try this code:


   string GlobalVar1 = "GVAR";
   long ChID = ChartID();
   
   if(GlobalVariableSet(GlobalVar1,ChID) == 0)
      Print("Error GV", GetLastError());

   Print(GlobalVar1," id:",ChID, " GV_id:", (long)GlobalVariableGet(GlobalVar1));


//мой ответ 2019.11.29 13:30:39.292     test EURUSD,M5: GVAR id:132194970392300419 GV_id:132194970392300416

разница в конце в одну цифру