![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
An example of using the GetPriceDiffInPoint() function.
Suppose we need to calculate the value in pips and the direction of rate movement between the second and first bars on the current chart. Suppose that the current chart is EURUSD H1. Call the GetPriceDiffInPoint() function with default parameters:
Here is the result:
The GetPriceDiffInPoint() function has returned -23 points. Let's analyze how it was obtained. For this purpose let's draw vertical lines through the hour bars 2, 1 and 0:
Let's switch to a smaller time frame, for example, M5 and mark the interval of bars 2 and 1 with a single rectangle on it:
Now we can clearly see that the first in the highlighted interval were two equal highs of 1.4283, and only after them, in the middle of the second hour was the low of 1.4260. Hence we conclude that during the last two hours EURUSD decreased and the value of this decrease was (1.4283 - 1.4260) / 0.0001 = 23 pips.
P.S. Attached is the script for testing the GetPriceDiffInPoint() function.
Awesome selection, isn't there a function to close an order (buy or sell) on the first successful close of a bar on any TF...
Can I ask what checks are made before orders are opened?
If they are collected in a separate function, please give me a link. If not, a list can be given.
Can I ask what checks are made before orders are opened?
Sergei, I can't think whether your question is for me or not?
...
The functions, opening, closing and modifying when handling errors use the Sleep command. I've done some research and recommend replacing it with one of these. The point is that the value of delay is a recommendation, and does not have to be strictly that value. Quite often, you can perform actions with an order right away (without a delay). But if you have a requote, then I do not like the fact that BC can calculate when and what type of operation I will perform.
Sergei, I don't know whether your question is for me or not.
Yes, Igor, it is a question for you.
The point is this. I looked at the opening function, there are no checks there. Apparently they are concentrated in some other function. If you have such a function, please give me the link. If you don't see such a function, you may write a list of checks right here. You may do it slowly.
No, Sergei, I don't do any more checks. Or rather, I do, but I don't put them in separate functions. That is, I put some of them... Geez, I'll give you an example:
What do we see here?
1. We calculate the lot to be traded.
2. If there is a Buy position with a specified magic number, its open price is defined po.
If there is no SellStop order and Sell position with a Magik by one unit larger than the specified one, we set the SellStop order at the price by offSet points lower than the opening price of Buy position.
4. In the interval we carry out calculation of price levels sl and tp.
4. In between, calculate price levels sl and tp.
That's what I mean. We have to take into account the existing constraints, which, generally speaking, change all the time.
Is there some function that analyzes all possible constraints?
Same for modification.
--
(I have 16 functions - 3 for each good order (OP,SL,TP) and 2 for each market order (SL,TP),
and then some more analyzing combinations of permissions).
Is there any function that analyses all sorts of restrictions?
GetTypePrice() function
Returns the name of the price type. The function accepts only one optional parameter. Valid values: PRICE_CLOSE, PRICE_OPEN, PRICE_HIGH, PRICE_LOW, PRICE_MEDIAN, PRICE_TYPICAL, PRICE_WEIGHTED. The default value is 0 - PRICE_CLOSE.
This function is useful for commenting or logging the work of indicators, scripts and Expert Advisors, in particular, for displaying the explanations of price constants' values.