[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 289
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I've written what happens if you just move the script to a folder with experts. It works, but not in the way it should. The script creates 8 pending orders but if we just save it in the folder with Expert Advisors, it creates 8 pending orders after each tick. I need it to place 8 new orders only after the old ones are closed.
Have you written only a "postponement" in your script? Then it will only procrastinate: as many ticks come in as it takes... oops... .........
You have to add a third checker-inhibitor in it...
This is what happens if the script is simply moved to the experts folder. It works, but not the way it should. The script creates 8 pending orders, but if you just save it in the Expert Advisors folder, it creates 8 pending orders after each tick. I need it to place 8 new orders only after the old ones are closed.
I found a mistake. In the library for this function on the line
should delete zero in each of the 13th, 14th and 15th numbers.Now correctly
Hello library functions.
Нашел ошибку. В библиотеке для данной функции в строке
надо удалить по нулю в 13, 14 и 15 числе.
Теперь правильно
Hello library functions.
Have you written only a "postponement" in your script? Then it will only procrastinate: as many ticks come in as it takes... oops... .........
You need to put a prohibition checker in there as well...
))))) Can't resist)))))
All right, let's get down to business. I'm working on optimization of code of the second TF, I've decided to translate double into int[2] to write the RateInfo structure in one block. I thought about it and decided to describe all possible ways, includingunrealizable ones, so that somebody could be warned against errors.
1. WinAPI (msdn). Generally speaking, there is not a lot there in terms of conversion functions. This is because conversion makes extensive use of the c-type translation, which is something like
in the next-to-last lineint i1 is converted to char and in the last line char s2 is converted to int. As the result all this stuff is used in so called "conversion functions" which in fact are not in any WinAPI dll, but declared in header .h files using macros like
which at compile time preprocessor unrolls into string like in the first code. And header .h files are not dll and are used only in development environment (Studio, Borland, gcc, etc). Therefore, it is neither good nor bad for MQL4. However, you can always check whether the function is declared only in the header .h-file or in hidden from prying eyes exported functions of some dll in System32.
2) WinAPI (CRT dll). These dlls are named msvcp*, msvcr*, msvcrt*, msvci*, msvcirt. Here the choice is wider: _atodbl, _atoi64, _atoldbl, _ftol, _i64toa, _itoa, _ltoa, _strtoi64, _strtoui64 _ui64toa, _ultoa, atof, atoi, atol, strtod, strtol, strtoul. The symbols in the name have the following meaning:
But the expected _dtoi64/_dtoui64 is still missing. Using the msvcrt*, msvci*, msvcirt.dll definitions, on the other hand
is only available, even if you get twisted, as a file operation (these are console operations).
You can search, apart from msdn, onthis site, here is the site search bar. A similar "handy" msdn search string is here. How do they differ? The msdn has a good description of the functions, but some are not there at all (NativeAPI, for example). On the alternative one, on the other hand, any system dll export table is there, but no description. Basically, a set of export tables on the website is easier than pulling export tables from the dll yourself (IDA, PE Explorer, etc.).
3. assembler inserts (more precisely, machine code inserts). I will explain in a moment, as the official documentation is very vague in this respect. The C++ inserts in MQL4
asm/_asm is not a function, but a preprocessor directive, and is not defined anywhere in system32/*.dll (see search within the site). In other words, there is no such thing.
You can write pure machine code in MQL4 but only in one case: when according to definition WinAPI-function in msdn it should pass a pointer to function/procedure likelpTimerFunc (completeexample here at forum), in msdn it is declared as:
UINT_PTR SetTimer( HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc//<- );
orlpfnWndProc (unfinishedexample here on the forum, msdn declaration and attempted mql4 structure declaration). There is no other way, MQL4 is an interpreter, the address of the function does not exist, there is nothing to pass, only if the code is written in machine code. They are then packed in an int array and passed to the function by reference.
So compiled assembler inserts (i.e. machine code) are not applicable to this task - they have a completely different scope. The most that can be achieved is to run such an int array via debug in cmd via shell32.dll. It seems that the command line cannot be passed there, but it can be written using the virtual keys via keybd_event.
4. Writing my own function to convert double into int[2] in pure MQL4 without inserts. But I've estimated the size of the code and its performance, and gave up. I haven't even written the module itself, but I believe the algorithm is as follows:
It would take a very long time to execute. So I finally came to the most obvious and easiest solution
5. Use of a self-written dll in C++. The code is as follows:
In the script.
Int upper[0] is reversed because we pass it by reference. We get:
...it worked, the lines in the dump are identical. Attached folder, in it in libraries is double.dll, in samples - source dll, in scripts - script.
In the evening: re-downloaded the archive and tampered with script and dll code a bit.
I don't understand what I've done wrong. For some reason the position is not closing as I had planned?
Here is the criterion for opening a position
Here's the criterion for closing a position
and here's what we get:
No! You can't touch functions from the standard library! Dima banned :-))
Why are you making a clownery here? If there is an error, you either need to report it to servicedesk, or make your own copy of the file.
I don't understand what I've done wrong. For some reason the position is not closing as I had planned?
Here is the criterion for opening a position
Here's the criterion for closing a position
and here's what we get:
And how often is the closing criterion checked? Not by bar by any chance?
And how often is the closing criterion checked? Not by bars by any chance?
I don't quite get the gist of the question. Opening price testing model (quick method on formed bars)