[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 278
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
Generally, like any other program, yours will consist of separate blocks, each of which performs some task. You take one such block and write your own code, debug it and then move on to the next block. And so on till the end of the program.Have you looked here? https://book.mql4.com/ru/samples/index
Thank you...
Good afternoon!
Please advise me on a reliable way to identify a flat, if there is one at all.
Good afternoon!
Please advise me on a reliable way to identify a flat, if there is one at all.
A flat is a price movement consisting of one or more flat elements.
A flat element is an element of the price movement formed when the price moves in any direction from its starting point with subsequent price rollback to this point.
For the delivery of the order the following command is used
The command OrderSend commands the robot to place the order; the currency pair is written in brackets in the first position. Here we have Symbol() that gives us the currency pair where the Expert Advisor has been placed. This is followed by the name of the trade operation. Then we have the lot volume and we have a variable multiplier here. Price, then a deviation of 3 pips, Stop Loss, Take Profit, name, magic number - any number you have chosen, then I don't remember, then colour. Everything is in this order. You can do without tikett=, just OrderSend.
And here, pay attention! The order will be placed on every tick, up to hundreds of orders, if it is just written in the start. We need conditions so that the order would be placed when it is necessary. Example.
Tired. Use the help, to analyse the ready examples.
Generally, like any other program, yours will consist of separate blocks, each block performs a task. We take one such block and write our own code, debug it from end to end and then move on to the next block. And so on to the end of the program.Have you seen it here? https://book.mql4.com/ru/samples/index
Well, I will try to be more specific... My Expert Advisor successfully opens ONE pending order and it has to modify it after some time... To do this, I need to know its index or a position number in a pending order. How can I obtain this position number or its index? Do we have to search for orders using a for loop? I have ONE order... Here is a part of the code of my program that doesn't work
if (OrderSelect (1, SELECT_BY_POS, MODE_TRADES)==true)
{ticket = OrderTicket();
return();}
How should I write it correctly?
And yet I will try to put the question more precisely... My Expert Advisor successfully opens ONE pending order and after some time it has to modify it... To do this, we need to know its index or a position number in pending orders. How can I obtain this position number or its index? Do we have to search for orders using a for loop? I have ONE order... Here is a part of the code of my program that doesn't work
if (OrderSelect (1, SELECT_BY_POS, MODE_TRADES)==true)
{ticket = OrderTicket();
return();}
How do I write it correctly?
The function OrderSend(), if executed successfully, returns the number of the ticket of the order it just opened - this is its sequence number on the server, and there is no other such order. So there is no need to run a retracement of the order, just remember its ticket. Just remember it as soon as the order is opened.
The OrderSend() function, if successfully executed, returns the order ticket number that it has just opened - this is its serial number on the server and there is no other such order. So there is no need to run a retracement of the order, just remember its ticket. Just remember it as soon as the order is opened.
And how long will we 'remember' him for? You could lose it...
IMHO - we should always take fresh and up-to-date information as we need it, rather than storing it in memory, dependent on the occasion.
It would be better to find the order right before modifying it rather than hope for the chance... Just in case the power is not switched off, for example...
And yet I will try to put the question more precisely... My Expert Advisor successfully opens ONE pending order and after some time it has to modify it... To do this, we need to know its index or a position number in pending orders. How can I obtain this position number or its index? Do we have to search for orders using a for loop? I have ONE order... Here is a part of the code of my program that doesn't work
if (OrderSelect (1, SELECT_BY_POS, MODE_TRADES)==true)
{ticket = OrderTicket();
return();}
How do I write it correctly?
Maybe it goes something like this:
Returns the ticket of the last set order or -1
When calling, please specify the required symbol and the EA's magik, for example:
This function will return the ticket of the last pending order placed at the current symbol (the only one in your case). Magic - the magic number of your EA
You could put the ticket in global variables as well. :) You can roll the hell out of it at all. But as an idea selection of the order before modification will work. Only if it is not necessary to reset lots only 1 time for all time of an order lifetime (with single modification at that) :) :).
In short, there are a lot of variants :)