Questions from Beginners MQL5 MT5 MetaTrader 5 - page 863
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
Can you show the code that prints the price of the nearest buy stop and the nearest sell stop?
Just the price? What is it for? And decipher the word "nearest" - to whom, what ...
Just the price? What is it for? And decipher the word "nearest" - to whom, what ...
Just the price.
Look.
We now have 10 buy stops 100 pips away from the current price.
We now have 10 sell stops 100 pips away from the current price.
I need to display the price of the nearest buy stop and the nearest sell stop relative to the current price in Print.
I tried to do it but it did not work.
The price of the nearest buy stop is output correctly, but the price of the nearest sell stop is output for some reason.
This functionm_order.PriceOpen(); always displays the buy stop price. Although I ask it to give me the price of the sell stop after the buy stop request.
This is done for further logic-
I divide by 2 the price of the nearest buy stop and the price of the nearest sell stop.
The Expert Advisor will continue its work based on the obtained figure.
The full function is
Now I've tried changing the code.
No change. Outputs only the buy stop price
Now I've tried changing the code.
No change. It only displays the buy stop price.
Let's write the code first. I would start by saying that the Buy Stop and Sell Stop search function needs to pass the price - otherwise how do you search? ...
Also, we need to clarify: "nearest" - above or below the price? Or is it just the difference between the set price and the pending order?
Let's write it up first. I would start by saying that the Buy Stop and Sell Stop search function needs to pass the price - otherwise how do you search? ...
This is how I do it.
The function perfectly outputs the current number of sell stops.
Next, we have selected the closest Sell Stop. We ask to display its price and print it
It is written in the help.
The COrderInfo class
PriceOpen
Gets the order price.
doublePriceOpen()const
Returned value
Order open price.
Note
The order should be pre-selected for access using the Select(by ticket) orSelectByIndex(by index) methods.
What is wrong? We have selected the order. The price of the installation is requested.
Or am I misunderstanding something ? Why do I get a buy stop price if I do not do it right?
Also, we need to clarify: is the "nearest" the top or bottom of the price? Or is it just the difference between the set price and the pending order?
Here is the price of which buy stop and sell stop I need
Here is the price of which Buy Stop and Sell Stop I need
This function searches for the nearest above Buy Stop from the price "price" and the nearest below Sell Stop from the price "price":
Now another problem)
I used to call my function like this -
Inserted your code and changed my function to
Now there is an error when compiling(
Now another problem)
I used to call my function like this -
Inserted your code and changed my function to
Now there is an error when compiling it(
You have to pass a PRICE to the function, around which the search for pending orders will be performed.
Besides this price you have to pass two variables: