[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 275
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
The question is.
How to get a number without minus, if it turns out that Open[1] < Close[1] and when you subtract Open[1]-Close[1] I get the value with a minus, how to make it was always a positive value, I need to calculate the distance between Open and Close maybe there is another way?
Thank you.
The question is.
How to get a number without minus, if it turns out that Open[1] < Close[1] and when you subtract Open[1]-Close[1] I get the value with a minus, how to make it was always a positive value, I need to calculate the distance between Open and Close maybe there is another way?
>> Thank you.
https://docs.mql4.com/ru/math/MathAbs
https://docs.mql4.com/ru/math/MathAbs
;) >> Thank you!
Good day!
When writing an EA for MT4, there was a need to determine programmatically (i.e. in the code of the EA itself) if at least one order of this EA was opened or not. Can you advise whether there is such a function? Perhaps, if there is, it would look something like this
Bool (has an EA order with this magic number been opened)
{answer= True/False}
?
Experts - help please - we are already wracking our brains
P.S.- tried the option with order numbers - didn't work
Good day!
When writing an EA for MT4, there was a need to determine programmatically (i.e. in the code of the EA itself) whether at least one order of this EA was opened or not. Do you know if there is such a function?
Will this function work?
Example usage: We put this function at the very end of our code and check it when we open a position:
If we don't look for positions but for pending orders, we can use this function
Function NumberOfOrders().
This function returns the number of orders . You can limit the list of orders to be checked using the function parameters:
sy - Name of the instrument. If we set this parameter, the function will only check the orders of the specified instrument. NULL means current instrument, and "" (default) means any instrument.
op - Type of pending order. Valid values: OP_BUYLIMIT, OP_BUYSTOP, OP_SELLLIMIT, OP_SELLSTOP or -1. The default value of -1 means any order.
mn - Order identifier (MagicNumber). The default value of -1 means any MagicNumber.
https://www.mql5.com/ru/forum/107476/page12
Please explain what the files provide:
If possible, in some simple way.
Thank you.
Please explain what the files provide:
If possible, in some simple way.
Thank you.
they are so-called "library files". these files store frequently used functions. they are used to avoid loading the source. if the library file is "declared", the functions from the declared file can be used as if they were included in the source.
Please explain what the files give us:
If possible, please keep it simple.
Thank you.
When using (calling) a function from these files (already initially built into mt4) we, in case of incorrect operation of the EA, can see in the log the number of the error we made in the code .
For example, we call the GetLastError() function :
In this case, if we made an error in the code or set incorrect external parameters, we will see the number of this error in the log.
For example, 130.
And the decoding of the number can be found at -https://book.mql4.com/ru/appendix/errors
And we do not need to go through the whole code, because we already know where the mistake is made!
Will this function work?
Example usage: we put the function itself at the very end of the code (outside the START function) and then check it when opening a position:
If we don't look for positions but for pending orders, we can use
Function NumberOfOrders().
This function returns the number of orders . You can limit the list of orders to be checked using the function parameters:
sy - Name of instrument. If you specify this parameter, the function will only check the orders of the specified instrument. NULL means current instrument, and "" (by default) means any instrument.
op - Type of pending order. Valid values: OP_BUYLIMIT, OP_BUYSTOP, OP_SELLLIMIT, OP_SELLSTOP or -1. The default value of -1 indicates any order.
mn - Order identifier (MagicNumber). Default value -1 means any MagicNumber.
https://www.mql5.com/ru/forum/107476/page12
Thank you very much for the tip, we tried it but it did not work, please check if there is a mistake somewhere in the code:
If we want to check if there is a Sell or Buy condition and we have not open or closed an order, in this case, only the first condition will work. And if the EA has already opened orders in the past, then, when an order is opened, the first + second conditions should trigger.
I looked through the link provided by you, maybe the ExistOrders(); is more suitable?
(but I honestly could not place it, since I apparently lack the skill for the time being).
You have not called the function correctly.
Your function is called like this: if (NumberOfPositions(NULL,Magic)> 1)
It should look like this:
Feel the difference (you omitted "-1") ! and RECTIFY YOUR CODE.
To control it, you can print a comment on the chart. For example, like this (at the beginning of the START function).
As for your second condition, I would ("without thinking too hard") set a different magician and separate function Open_Buy_2() to open positions by the second condition !The code of the second condition would look like this