[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 383
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
Good afternoon. I have the following question. TheMQL4book located at MQL4.community, in the "Simple MQL Programs " section, contains an example of tradingexpert.mq4 with the following content (see attached file). External variables extern double StopLoss =200 and extern double TakeProfit =39 are declared in block 1-2. Block 8-9 calls of the New_Stop(StopLoss) and New_Stop(TakeProfit) functions are used to calculate SL and TP parameters. There is a description of the function in block 11-12.
Question: The formal parameter of New_Stop function has int type(int Parametr), while the parameters passed in function call New_Stop(StopLoss)(New_Stop(TakeProfit)) have double type... In MQL4 book, found at MQL4.community in chapter "Language Fundamentals" in section "Functions", subsection "Function Properties" says "The number, type and order of parameters passed in a function call must match the number, type and order of formal parameters passed in the function description (the exception is a function call that has default parameters - see Function Call and Function Description and Return Operator. How to explain this contradiction: according to the latter, when declaring StopLoss and TakeProfit variables, I should have indicated int type, not double(the compiler gives no error)?
Thanks in advance for the answer, not to litter the forum.
The external parameters (extern double StopLoss =200; extern double TakeProfit =39; ), in principle, should be of integer type (more exactly, according to author's idea - it is a value in points). When calling the function, the implicit type conversion is used. The floating-point type is converted to integer type with loss of precision. In this case it doesn't matter: the size of stop and profit as intended is set in pips - it is always integer.
IMHO, the example code is poorly written.
Using the absolute value of constants is a very bad and wrong style, with mnemonic names.
The worst implementation of the order enumeration: it's hard to think of a more "retarded" one. It seems to be deliberately slow: extra calculations, unnecessary function calls - the most expensive operation in terms of time, and on each iteration of the loop. And this despite the fact that the number of orders does not change inside the loop.
Sorry, but I used to work on Rumuse and now I'm learning MT4. I'm still a "Dummie" here . 11 .09 . I can't start the quotes. Please tell me what is wrong. I will be glad to help you.
Hello, can you tell me how to disable an EA if an order opened by the same EA is closed by a trader or by SL or TP.
BeerGod
Понимаете, советники на то и советники, что не нужно им советовать... а если ордер открыт, то не переживайте, дядя Коля прийдет и всё закроет.
So it is not possible to stop the EA working?
BeerGod
So it is not possible to stop the EA?
Disable the EA by pressing the button in the terminal, and the order cannot be rolled back of course, close it manually.
BeerGod
Disable the EA by pressing the button in the terminal and the order cannot be rolled back, of course, close it manually.I am writing an owl which opens an order with SL and TP.
I need a condition that if an order is closed by TP or closed by a trader I have to stop the EA. How to implement this programmatically?
Help me solve the problem, why if the loop has only 2 passes i first equals 0 and then immediately equals 4?
From this script the alert outputs 0, 4.
As far as I understand the code
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == false) break;
does a break, which means we go to the beginning of the loop and increase i according to the loop condition
probably like this
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == false) {i--; break; }