[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 396

 
rajak:

Hello all!

Can you advise, if anyone knows what the problem is, after compiling file ex4 does not appear, through metalang too. What can I do about it, and a couple of days ago everything was working fine.

The compilation runs without errors, even if you introduce them purposefully.

If you have windows7, try to look in the virtual folder

c:\Users\Your folderAppData\Local\VirtualStore\Program Files (x86)\MT4 folder\experts\

Instead of your folder and MT4 folder, substitute your real directories.

 
lottamer:

Some time ago, kind people told me how to make the function "return ticket of the last closed position" from the function "return ticket of the last two closed positions".

And when I needed function "tickets of three closed positions", I could not (by similarity and selection method) implement it

help please,

you can see that there are two copies, the second one with some changes. but i was able to continue them...

I have this variant for the 3rd ticket... and it returns the ticket of the first position again for some reason...


Replace

if(OrderTicket()==A && (OrderTicket()==B) )continue;

to

if(OrderTicket()==A || (OrderTicket()==B) )continue;

Just not clear what you are doing to return three values from one function

 
Roger:


Replace

at

It is just not clear what you are doing to return three values from one function



the point is to calculate the result of the last N positions. for that i call their tickets, and then it's a matter of technique

fLastClosetPoz();
     OrderSelect( Ticket1,SELECT_BY_TICKET); X=OrderProfit(); SL1=OrderType(); TM1=OrderOpenTime();      Print (Ticket1); Print (SL1,"_",X); //ПОСЛЕДНИЙ 
     OrderSelect( Ticket2,SELECT_BY_TICKET); Y=OrderProfit(); SL2=OrderType(); TM2=OrderOpenTime();      Print (Ticket2); Print (SL2,"_",Y); //ПРЕДпоследний
     OrderSelect( Ticket3,SELECT_BY_TICKET); Z=OrderProfit(); SL3=OrderType(); TM3=OrderOpenTime();      Print (Ticket3); Print (SL3,"_",Z); //ПРЕД-ПРЕДпоследний
 
Roger:


Replace with

to


It worked! Honestly, I had this idea of substituting OR for AND.... but ... :)))))))))))))))))))))

thanks ! now i understand the logic, although to count 15 closed ones, i will have to blow the code to the size of a balloon !

can it all be squeezed into one loop ? and only substitute the parameter of the number of required trades N ?

 
Zhunko:

1. You shouldn't do that. It even expresses my admiration for his algorithm. That's the HENRYFIX. He had a different nickname back then.

The prefix of the script name is the first letters of our nicknames.

===============

2. Dmitry, no matter what, I'm sincerely glad that you've solved some secret problem with some secret algorithm, which is not subject to disclosure.

3. Everything looked very mysterious. Thanks for bragging. You are undoubtedly the coolest programmer on this forum and maybe even in the entire universe!

1. Oh yeah! After finding out it was your code, or your buddy's. Abalde, was the most fucked up and embarrassing, now it's immediately become admirable.

2. With what I am a programmer, what I know and how I know and can do, with what I do not know and do not know - I'll deal with it somehow.

3. The task is absolutely not secret, it is absolutely clear, it has been openly defined here. All who are able to understand it, understood it at once without any problems. It has been solved not by some secret and magical methods, but by the usual standard and obvious (and world-known) ones. I'm not bragging here, and at you, miracle, I'm laughing. Only your megalomania prevents you from understanding and realising this.

 
Integer:

1. Oh yes! After it turned out to be your code, or your mate's. Abaldez, was the most fucked up and embarrassing, now it's immediately admirable.

2. With what I am a programmer, what I know and how I know and can do, with what I do not know and do not know - I'll deal with it somehow.

3. The task is absolutely not secret, it is absolutely clear, it has been defined here in an open way. All who are able to understand it, understood it at once without any problems. It has been solved not by some secret and magical methods, but by the usual standard and obvious (and world-known) ones. I'm not bragging here, and at you, miracle, I'm laughing. Only your megalomania prevents you from understanding and realizing that.




You guys, go rub it in some other place! People are solving PRACTICAL problems here. and you are littering the thread with emotion...
 
lottamer:


Youguys go rub it in some other place! People are solving PRACTICAL problems here. you're littering the thread with emotion...


Why are you writing to me about this? Take Junko and write that, it's his fourth day here he can not understand what we are talking about, all the rest have understood on the first day.
 

Of course, there have to be limits to any debate. Otherwise, it may already cross the boundaries of reasonableness.

After both positions have been stated, the parties may or may not agree. - That is their right. Even if people are wrong. Everyone has the right to be wrong.

If it is a public debate, like this one, then those watching see the arguments of each side and, regardless of the consensus reached (or not) on the issue, everyone has the opportunity to choose their version of the solution (or both).

But to turn to accusations and appeals to the individual (rather than the task, the issue, the case) is already to lower one's credibility. It is unnecessary and condemnable (for insulting a person).


Since the arguments and ways of solving the problem have long been laid out, I suggest that both sides stop on this issue and appeal to each other.

Apparently, if the debaters are professionals in solving programmatic issues, they are newbies in debating issues. Which is not out of line with the topic of the thread, but allows professional advice to be given. I hope this advice is heeded.

 
Integer:

1. Oh yes! After it turned out to be your code, or your mate's. Abaldez, was the shittiest and most embarrassing, now it's immediately become admirable.

2. With what I am a programmer, what I know and how I know and can do, with what I do not know and do not know - I'll deal with it somehow.

3. The task is absolutely not secret, it is absolutely clear, it has been openly defined here. All who are able to understand it, understood it at once without any problems. It has been solved not by some secret and magical methods, but by the usual standard and obvious (and world-known) ones. I'm not bragging here, and at you, miracle, I'm laughing. Only your megalomania prevents you from understanding and realising this.

1. Do you know the difference between a code and an algorithm? What's more, the algorithm has nothing to do with opening the chart window. I have fixed the code, of course. The place where the chart opens hasn't virtually changed. There was no other way to do it at that time. I did it in a different way in the DLL. It is more reliable.

2. That was great! You're the best!

3. You mean it:

FAQ:

1) Problem : every script (EA) has to be aware of the presence of all the others.

2) Problem : if there is a failure, the globals from the failed one will hang untouched and the queue will get stuck.

3) Solution :

Each exp organizes 1 globalka with name - common prefix + window handle + symbol. value of the globalka is time of last tick on that instrument. 2 common global with its own handle (after working it writes its own handle into it or clears it if it is the oldest)

The queue is arranged in ascending order (handles), the most senior sets the second globale to zero

in each exp, we create three arrays (for lack of structures) - symbol/handle/last access time/last tick time.

all EXPs keep track of (last access time/last tick time) for all of them and as soon as they are different (one of EXPs fails) both globals of the failed EXP are deleted and it is considered inactive. its cells in the arrays are deleted (the array is rebuilt).

queue is restored

this will actually be done by the EA standing on the most active chart (frequent ticks).

when deinitialized normally, each expo will clean up after itself.

max skip - one tick.

ZS. and in general, it's better to do one multicurrency

So this is thanks to Rustam's telepathic abilities. It's a hypothetical problem and a hypothetical solution. What does it have to do with your problem? You never said anything about it. I had to pry. The answer is nothing but profanity instead of constructive words, which you keep suggesting, but do not implement.

I had a similar challenge in 2008. Secrets will not do, as some. I will give a concrete example of what kind of problem, how to solve it, and why I think that solving such problems in this way is unsuccessful.

============================

The initial data of the problem:

1. The task has several identical looped experts. I.e. fully independent threads.

2. There is a database of coefficients divided into 8 groups, which is accessed by some experts. DB size starts from 2 Gb.

3. DB is sometimes replenished. Replenished in periods multiple of 2 hours. Processing time depends on multiples of time of day. Duration varies from 5 minutes to 45 minutes depending on the multiplicity of the time of day and CPU capacity.

Task:

Since supplementing the database takes a lot of time, only one expert should be responsible for supplementing the database. Otherwise, you may not be able to wait for it to finish.

2. It is necessary to prohibit access to the database while it is being updated. Do it in groups, so as not to significantly slow down updating of coefficients, with which the experts work.

Experts working with coefficients, which are currently being updated, should work with old coefficients.

Experts who have been switched to a specific group of coefficients during the period of updating should work with a single coefficient and inform about it. When the update is over, they should switch to the new coefficient. The same applies to point 3.

Solution at the time:

1. A common queue of expert identifiers consisting of their indices is made.

2. A queue of identifiers of experts, which access the database, consisting of their indices, is made.

Both queues are a common resource. Access to the queues is synchronized by a single synchronization object.

The first expert of the second queue is responsible for updating the database. 4.

5. Further, it is almost as Rustam described. It is a little bit easier due to the implementation in DLL.

The identifiers are the through indexes. When we delete an Expert Advisor, the identifier is removed from the queue. Reindexing is not carried out. Remaining experts will leave their indexes.

When adding a new expert, if the index of the last expert does not match their number, the first free old index is assigned. Otherwise new indices are assigned.

Binding to the descriptor and chart instrument is not necessary. Also, there is no need to keep track of an unloading failure. There has never been a failure. Even if it happened, it would not be a disaster. The EAs would continue to work with the old ratios. By the next update, the update counter controller would have detected no update and dropped the lead EA's ID from the second queue. The next expert would pick up the master's mission. The same controller would do the same thing when the Expert Advisor goes into database connection mode. I.e., it enters it into the second queue. I.e. only experts working on M1, where coefficient value is not critical, would be affected.

Such a solution fully accomplished the task, but I strongly disliked it because of binding of the Expert Advisors to each other and unusual task for the Expert Advisor, which was feeding the database, which does not add to the reliability. At that time I didn't know and didn't know how to do a lot of things. A year later I redid it.

Solution 2:

1. The database is maintained in a separate thread, where it replenishes itself on a timer.

2. Access to the database at the moment of its replenishment is protected by the synchronization object.

It all turned out much simpler. Without queues. But I didn't like it much either. Before a replenishment, the database called the script of quotes swapping which sometimes led to the memory overflow. Which slowed down MT4 a lot. At that time MT4 was working with 2 GB of memory. It's now running with 4GB.

Solution 3:

1. DB is a separate application. I.e. another process with its own dedicated memory, independent from MT4.

2. DB is replenishing itself.

Data exchange takes place through mapping. It increased the speed of data exchange and replenishment of the database. Earlier everything was read from the disk. It was impossible to do it otherwise. The working memory of МТ4 is very limited.

4. The history is pumped by MT4 remotely from the DB application, where you kick it as required. Any failure of MT4 - its unloading and subsequent loading.

5. Point 4 is done by creating a symbolic link to the current MT4 directory. I.e. it is a full copy of the current MT4. The history is updated on the fly directly into MT4 directories, without waiting for the working MT4 upload.

6. Synchronization of access to the database at the moment of its updating through mutex, because the critical section works only for one process.

========================

So, Dmitry, not knowing your task, you may suppose that it may be solved without organizing of queue and keeping Expert Advisor threads independent. It will increase the reliability and overall performance. I have been talking about it (independence of threads) for several pages already.

 

Sorry. No answer to that:

Integer:

It's an atomic access unit and no synchronisation. It doesn't make sense to only address the deposit in this way. Calling any of the deposit parameter functions will be atomic by itself, without any tweaks. If you do it atomically, all the work of the Expert Advisor. That's how you solve problems - you think you've done something, but in fact it's an illusion.

Dmitry, you shouldn't think that only fools are around. From Sergey's question, you can see that he has a good understanding of the problem.

Of course, a simple reference to the deposit parameters with synchronization is meaningless. Synchronization is needed to change these parameters. So that the parallel Expert Advisor receives the correct parameter that has already been changed, rather than getting it in the process of changing it.

Reason: