Useful features from KimIV - page 126

 
khorosh:
Put yourself in his position. Life in a foreign land, far from your homeland, does not go away. I'm irritable, angry at myself for having made an irreparable mistake by becoming a guest worker).
Error-checking is working properly, but so far no errors, despite many attempts to hinder normal functioning. I have sufficient protection against all possible contingencies. Again, the future will show!
 
artmedia70:

I deliberately made if(OrderSelect(i,SELECT_BY_POS)) a separate block. In order to return the error value during debugging. else {// write the selection error as you like and return from it, for example EMPTY}.

And let's think of a situation where there is an error of selecting an order to be placed in the market. Let's discuss it. I haven't come across one yet.

Roger:

And name at least one reason when a correctly created order loop may return "false".

Oops, didn't notice Artem already asked, oops. And yet.

What difference does it make?

In the general case it may return. So what if observation of some conditions or even a set of different conditions shows that it does not return false?

We don't know the details of implementation of this function and the documentation doesn't provide any "guesses" concerning it. What if, at the next set of conditions at the next broker, the function suddenly returns false?

I will still answer the question posed about the reason/situation, because it's easy: the reason could be an implementation error of this function made by the development team when the next version of MT was released. I hope this is a probable enough event to be seriously considered?

Suppose that because of this hypothetical bug, the function started randomly, but, on average, only for every 5th request, to return false.

Usually you can't think of things in advance that you don't know. So there's not much point in asking what it might be because of. When it happens, then you can easily explain why.

But not knowing what might happen in the future does not prevent you from defending against it. It may turn out that some high-level algorithms will make a lot of trouble because of a received false value. They won't know that the value is false.

But if they know that there is no value and if there is, it is true, they won't make a mess if there are no errors of their own. And that's why information about impossibility to calculate the value should be given not only in debugging mode but in combat mode as well.

 

Is it possible to load external data into the indicator, say from a text file?

For example, is there a daily price and it needs to build a line on any timeframe chart?

DATE Price

04.12.2014 100.00

03.12.2014 101.12

02.12.2014 102.45

01.12.2014 103.23

28.11.2014 102.43

27.11.2014 101.90

 
Good features, thanks to Igor for his hard work.
 
KimIV:

Examples of using the OpenPosition() function.

1. Buy 0.1 lot of the current instrument

2. Sell 0.2 lots of EURUSD

3. Sell 0.12 lots of USDCAD with a 20 pips stop

4. Buy 0.15 lot of USDJPY with 40 pips stop

5. Sell 0.1 lot of GBPJPY with stop 23 and takeaway 44 pips

Attached is the script for testing of the OpenPosition() function. The first 4 examples are commented out.
I don't know if you will answer or not. i'm sitting here, i don't know how to make my EA multi-currency!
 
logut:
I don't know if you will answer me or not. I'm sitting here and I don't know how to make my EA multi-currency!
Dmitry, I usually write out all the logic on a piece of paper. What to do and when, and with what.
 
Roger:

And give me one reason why a correctly created order loop might return "false".

Oops, didn't notice Artem already asked, oops. And yet.

Easy!

After another update the terminal rebooted and only started showing orders from the last day. It doesn't show orders history. The function should return something - like no history.

The broker deleted some orders.

There is a hole in the main memory. Your memory has crashed and the function is taking a rubbish memory cell. It may show up on the monitor. It may or may not appear. There may be other hardware problems.

The terminal reboots and "loses" communication with the server. I used to use Mt3 using proxy server. I used to have dialup internet with very limited bandwidth and time and the quality of the internet was horrible. I see ticks coming and the chart is moving. When I tried to open an order the terminal tried to write "no connection with the server".

I faced with a problem in MT4 and it still exists: I got a tick and a black (empty) chart screen. If I pull the chart with my mouse or the robot comes up with an error, I will get an error message and the robot will crash. If I pull the chart with mouse or a new tick comes, everything is normal. Therefore, when dividing, I first check what to divide by and if it is not equal to zero, I move on!

 

Dear KimIV, I am using your function to close all positions when a certain profit has been reached and I have encountered a situation where a pending order has triggered another position that has not been closed. I have now implemented additional checking of such a situation and repeated calling of your function. Do you think this improvement should be implemented inside the function after the main closing cycle is over?

These are functions ClosePosBySortLots() and ClosePositions();

 

There are function codes for removing pending orders both for online and for history tests - https://forum.mql4.com/ru/38949#434195

can you explain the difference between tests and online?

 
The isCloseLastPosByStop() and isCloseLastPosByTake() functions do not always work correctly, because the closing price of the order and Stop Loss (TakeProfit) do not always coincide. I have redone it in mine. I've replaced the condition of equality of these values with the condition: the absolute value of the difference of these values (at 5-bit quotes) must be less than 5*Point.