Useful features from KimIV - page 3

 
KimIV:

Function ExistOrders().

Returns a flag for the existence of an order. ...

I have made (for myself) "return" the number of orders. It immediately kills 2 birds with one stone (no need to write 2 functions) - if > 0, the order exists + we may analyze ... If there are "holes in the grid", triggering of "reversals", etc. (Although, the function takes too long to work. (True, the function takes longer to run, which is not justified for the purpose of stating only)

Plus, it seems to me, that it's visually more intuitive and, having assigned a variable, you can use it further

... (ExistOrders("", OP_BUYLIMIT)+ExistOrders("", OP_SELLLIMIT)) > 0 ...

than ...

... (ExistOrders("", OP_BUYLIMIT) || ExistOrders("", OP_SELLLIMIT)) ...
 
SergNF писал (а):
I have (for myself) made a 'return' of the number of orders.
There will be a NumberOfOrders() function later.
 
KimIV:
zhuki wrote (a):

Show your version of delays between trading operations

I do not make delays between trade operations. That is, if I need to place two or more orders, I make these trades without a pause between them. However, between trade attempts, which have to be repeated if there is an error when accessing the server, I make a pause according to recommendations of MT4 developers. As an example you can see how such pauses are implemented in my SetOrder() function for online trading. Different pauses are made for different errors returned by the trading server.



This function SetOrder() is used for setting pending orders. It is recommended for use in online trading on demo and real accounts.


If more than 20 EAs are trading, error 146 always occurs. The function is only able to solve the problem for a few (2-4) EAs, but, in principle, a fixed delay does not solve the problem...
When trading with 20 or more Expert Advisors, it is necessary to arbitrage, at least using Ethernet protocol... Then every Expert Advisor will be able to enter the market when receiving a signal.
 
Igor, please "treat me" to the order closing and modification functions. ;-)
 
Lukyanov:
Igor, please "treat" me with functions to close and modify orders. ;-)

Yes, definitely... But I'll finish with the SetOrder function first. I'm now waiting for the opening of trades to give more examples of how to use this function with records from the protocol. The test script is already ready, but it needs to be tested online.

Plan to publish the functions in alphabetical order:
- DeleteOrders
- ExistOrdersByLot
- GetLotLastOrder
- GetOrderOpenPrice
- IndexByTicket
- ModifyOrder
- NumberOfOrders
- SelectByTicket
- SelectByTicketFromHistory

You (thread visitors) can adjust the publishing sequence with your wishes. But first of all I will consider logical use of the functions, because many of them are connected with each other. In other words, the first to be published will be the functions that can be used in applying other functions, placed later.

 

Igor, you're doing a good job!

However... with so much baggage, and the forum and the book, the reference and the kodobase.
I still have burning questions that are sometimes embarrassing to ask.
(Fortunately, I am a dummies, and do not hide it ... but still learning ... :))

And questions exactly in those trifles and nuances, which allow you to connect pieces of code
...more precisely, to ensure that the blocks (modules) in the program are interconnected...

I understand, and I often sin myself when the question how?
The best case scenario is the following: but how...
For example, trailing stop. And when asked if you can use your own TS
When you ask if you can use your own TS, the answer will be at best: in 100% of cases yes, in 90% of cases add your own TS, in 80% of cases ask which one you are going to use :)))
etc... in descending order...
And how exactly, letter-by-letter, alas, is not always the case.

So I too will look forward to posts describing modification functions,
and perhaps a more detailed application of them in practice...

 
klot писал (а):
When trading with 20 or more EAs, you need to arbitrage, at least using the Ethernet protocol... Then every Expert Advisor can enter the market when receiving a signal.
What do you mean by "arbitrage"?
 
kombat писал (а):
And the questions are in those trifles and nuances, which allow you to connect pieces of code
More precisely ensuring the interconnection of blocks (modules) of the program...

Regarding my functions, I will answer any questions. If I can :-) ... That's what the thread is for. That is, you can ask questions here from other threads where I have posted my functions without giving detailed explanations. So feel free to do so. This is a topic I plan on keeping for a long time. I've planned 4 months for feature posting alone. Plus more answers to questions...

kombat wrote (a):
So I too will impatiently wait for posts with description of modification functions,
and maybe more detailed application of them in practice...
The ModifyOrder function is universal. It applies to orders as well as to positions. I will think about integrating it into the theme as soon as possible.
 
KimIV:
klot wrote:

When trading with 20 or more Expert Advisors, you should arbitrage, at least using Ethernet protocol... Then every Expert Advisor will be able to enter the market when a signal is received.
What do you mean by "arbitrage"?

Hello!
By "arbitrage" I meant providing a guaranteed access to trading flow to many Expert Advisors working simultaneously. I faced this problem a long time ago, and came to a conclusion that it is better to use multiply-access with collision detection from the Ethernet protocol.
The gist is simple. We check if the trade stream is busy. If the flow is busy we generate a random pause (starting from 1 second). If the trade flow is free, we "send" an order immediately. When trading using multiple Expert Advisors, each Expert Advisor will have its own random pause and the Expert Advisors will occupy the trade thread in turn. There will be no conflicts between experts.
For example:
if( IsTradeContextBusy() )  Sleep(MathRand()+1000);
 
If 10 experts are waiting for a trade flow to be released (each in their own independent flow) what can happen if by chance at least 2 coincide.
I calculate and use other principles. If a trade thread is occupied by someone, the remaining EAs simply do not work (return) and this is checked at the beginning of an EA (why analyze it if nothing can be done anyway).
I don't think so, thank you.
Reason: