![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
MA. I'll keep the post for 24 hours - then I'll delete it!
You don't have to delete it! Let it stay...
Igor, first of all thank you for your functions and for this branch, they help many non-professional programmers. But I'd like to ask you a question about the NumberOfOrders() function. I can't get it to work. I put it into a standard MACD Expert Advisor to give an example of how I use it. I am pasting the code:
To describe it briefly, it's changed there:
Naturally, it doesn't work. Could you please explain what's wrong? Thanks in advance.Could you explain what's wrong? Thanks in advance.
Two comments:
1. I would do it like this:
2. Function NumberOfOrders() returns the number of orders - trades of BuyLimit, BuyStop, SellLimit and SellStop types. The Expert Advisor that you have modified does not work with orders. It opens positions at market prices, i.e. performs Buy and Sell trades. You need to use the NumberOfPositions() function, which I will post in the next post.The NumberOfPositions() function.
This function returns the number of positions currently open. A more accurate selection of counted positions is specified by external parameters:
Wow! I thought it was a design:
would go through all positions (including OP_SELL and OP_BUY). Everything is working now. Thanks again!GetProfitFromDateInCurrency() function.
This function returns the total profit in the currency of the positions closed since a certain date. More accurate selection of positions to be taken into account is specified using external parameters:
HH. Attached is a script to test function GetProfitFromDateInCurrency().
The i-Profit indicator, which shows absolute and percentage profit values for different time periods, is a more practical example of how to learn how to use this function.
Hello Igor.
I would like to say thank you for the correlation fic. I had some options, I just wanted to clarify them)
I also have such a question. I very often encounter error 130 - wrong stop during testing of Expert Advisor in the real time mode. I do not analyze it, I do not understand why it occurs in one situation or another. I have started to use this construction
I've started to use this construct to normalize stop and TP, but it didn't solve the situation. Maybe you've faced similar situations, tell me how to deal with it and what's the best way to analyze it.
To clarify: This happens very often when I try to set a stop at +1 p from the open price
encounter error 131 - Incorrect stop.
131 - Incorrect volume, error in volume granulation. This is the size of the lot being traded.
I encounter error 131 - Wrong stop.
131 - Incorrect volume, an error in volume granulation. This is the size of the lot being traded.
Wrong code, not 131 but 130
Wrong code, it's not 131, it's 130.
I see...
Try normalising as follows:
I do so and I don't encounter error 130.