
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
first let me understand what u what compare the OrderOpenPrice or the symbol or TP or what?
thanks
I would like to compare the profit of the order 1 and 2, then order 3 and 4 then order 5 and 6 ... etc
for (int i = 0; i < OrdersTotal(); i++){
(OrderSelect(i, SELECT_BY_TICKET)) = int ticket A
No. Select by pos as usual to loop through the orders. but after selecting immediately save the value of OrderTicket() (and also OrderProfit() or whatever you want to compare with other orders in the inner loop)
then do your inner loop as usual or whatever else that will disturb the current selection.
then, back in the outer loop, if you still need the order of the outer loop, restore the selection with SELECE_BY_TICKET.
No. Select by pos as usual to loop through the orders. but after selecting immediately save the value of OrderTicket() (and also OrderProfit() or whatever you want to compare with other orders in the inner loop)
then do your inner loop as usual or whatever else that will disturb the current selection.
then, back in the outer loop, if you still need the order of the outer loop, restore the selection with SELECE_BY_TICKET.
thanks, something like these?
for (int i = 0; i < OrdersTotal(); i++){
(OrderSelect(i, SELECT_BY_POS))
int ticket A = OrderTicket();
double profit A = OrderProfit();
}
for (int j = 0; j < OrdersTotal(); j += 2) {
(OrderSelect(j, SELECT_BY_POS))
int ticket B = OrderTicket();
double profit B = OrderProfit();
}
ex.
if (profit A + profit B) > 5
{
then OrderClose both ticket A and ticket B
}
but how do I combine them? Both the loop needs to be in a bigger loop right?
Would ticket and profit A and B be updated by the loop to order (1 and 2), then order( 3 and 4), then order (5 and 6), (7 and 8) and so on ... ?
Your code examples look like you have not done much programming before. You would have to nest one loop inside the other and do the comparison in the inner loop. And then break out of the inner loop once you found a match.
Maybe it's a good time to pause your experimenting with mql4 for a while (since it is incredibly painful to learn the basics of programming with it) and rather acquire and practice the most basic ideas and concepts in programming with a language that is easier to use and debug. ANY other language will do. Try Java, it has a quite similar syntax but is much easier to learn the basic concepts. Install NetBeans and try some Java tutorials and then do loops and nested loops and how to break out of them and functions, variables, assignments, etc., all the basic stuff until you get a feel for it.
[Edit:] OP has deleted the posting for which the following was the answer:
Java is not harder, its actually exactly the same (or even easier) if you restrict yourself to procedural programming. This is not about learning their huge repository of libraries, you don't use them for learning the language, this is about simple concepts like variables, loops and functions.
The difference is you don't have to fiddle around with MT4 and its requirements and its limited means of debugging and actually seeing what is going on.
You can just write the code and click a button to execute it and see the output or even let it step through the code line by line and show you the contents of variables and how they change as the program proceeds line by line so you can follow the program flow. This is great for learning.
[Edit:] OP has deleted the posting for which the following was the answer:
Java is not harder, its actually exactly the same (or even easier) if you restrict yourself to procedural programming. This is not about learning their huge repository of libraries, you don't use them for learning the language, this is about simple concepts like variables, loops and functions.
The difference is you don't have to fiddle around with MT4 and its requirements and its limited means of debugging and actually seeing what is going on.
You can just write the code and click a button to execute it and see the output or even let it step through the code line by line and show you the contents of variables and how they change as the program proceeds line by line so you can follow the program flow. This is great for learning.
Thanks GUYS! Going to try if this will work, no error compiling.
Thanks GUYS! Going to try if this will work, no error compiling.
johnnybegoode:
I would like to loop comparison of (1st with 2nd) orders, (3rd with 4th), (5th with 6th), (7th with 8th), (9th with 10th) ....till i, TotalOrder
(OrderSelect(0, SELECT_BY_POS)) // assuming the 0 is the first order (correct me if I am wrong)
and
(OrderSelect(1, SELECT_BY_POS))
then compare them
while still inside the total order loop
(OrderSelect(2, SELECT_BY_POS)) and
(OrderSelect(3, SELECT_BY_POS))
u r going to compare the first order with himself
Ya, does not work and only 1 order is close and not both together
Thanks, but is this comparing 1 with 2, then 2 with 3, then 3 with 4?
I need to specifically compare order
1 & 2 only
3 & 4 only
5 & 6 only
..... and so on
other orders should not be compared.