Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1682 1...167516761677167816791680168116821683168416851686168716881689...1965 New comment Nerd Trader 2021.10.18 22:25 #16811 Reworked a bit, now do while instead of the main for loop, but still no occurrence of the first condition in the second nested loop! int GetMagic(Order &order) { int magic = 0; int unique = 0; if(order.cmd == OP_SELLSTOP || order.cmd == OP_BUYSTOP){ if(OrdersTotal()){ do{ magic++; for(int i = OrdersTotal(); i > 0 ; i --){ if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){ Print( "!!!!!!!!!!!!!!!!!!!");//<----------НЕ ПРИНТУЕТСЯ if(magic != OrderMagicNumber()) unique ++; } } }while(unique < OrdersTotal()); }else return (magic + 1); } return magic; } Vitaly Muzichenko 2021.10.18 22:49 #16812 MakarFX #:Really?!)) Have you tried it? I've had the colour change working that way for a long time, but not on the line, although it should make no difference if(SymOpen < SymClose) { CColor=Mirroring?BearBarColor:BullBarColor; SetIndexStyle(32+(num*8),DRAW_HISTOGRAM,STYLE_SOLID,Mirroring?1:WidthOC,CColor); SetIndexLabel(32+(num*8), SubSymbol); SetIndexStyle(33+(num*8),DRAW_HISTOGRAM,STYLE_SOLID,Mirroring?WidthOC:1,CColor); SetIndexLabel(33+(num*8), SubSymbol); SetIndexStyle(34+(num*8),DRAW_HISTOGRAM,STYLE_SOLID,Mirroring?WidthOC:1,CColor); SetIndexLabel(34+(num*8), SubSymbol); SetIndexStyle(35+(num*8),DRAW_HISTOGRAM,STYLE_SOLID,Mirroring?1:WidthOC,CColor); SetIndexLabel(35+(num*8), SubSymbol); PS. Looked at my other code, it changes the colour of the line there SetIndexStyle(num,DRAW_LINE,STYLE_SOLID,1,BullColor); Tretyakov Rostyslav 2021.10.18 23:01 #16813 Vitaly Muzichenko #:I've had a colour change working that way for a long time, but not on the line, although it should make no difference PS. Looked at my other code, it changes the colour of the line SetIndexStyle(num,DRAW_LINE,STYLE_SOLID,1,BullColor); Changes the whole line, not the desired section Vitaly Muzichenko 2021.10.18 23:02 #16814 MakarFX #:Changes the whole line, not the right section Well, he wrote that you have to change the whole line Nerd Trader 2021.10.18 23:06 #16815 So, I've adapted the code for the test, try running it and you get an infinite loop on the second order :( Files: endless_cycle.mq4 2 kb Vitaly Muzichenko 2021.10.18 23:13 #16816 Nerd Trader #: So, I've adapted the code for the test, try running it and you get an infinite loop on the second order :( I wonder! Why? Why this, what sacred meaning does it have? int GetMagic(Order &order) { int magic = 0; int unique = 0; if(order.cmd == OP_SELLSTOP || order.cmd == OP_BUYSTOP){ if(OrdersTotal()){ do{ magic++; for(int i = OrdersTotal(); i > 0 ; i --){ if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){ Print( "!!!!!!!!!!!!!!!!!!!");//<----------НЕ ПРИНТУЕТСЯ if(magic != OrderMagicNumber()) unique ++; } } }while(unique < OrdersTotal()); }else return (magic + 1); } return magic; } --- You're searching by number, so search by number. If you have 2 warrants, he'll go through them, but he can't find the 3rd, or the 23rd. --- You don't seem to be quite clear on the task, so that's the solution. given an indicator handle, Error with script Absolute courses [Deleted] 2021.10.18 23:18 #16817 Nerd Trader #: the loop is not set correctly: for(int i = OrdersTotal(); i > 0 ; i --){ it should be like this: for(int i = OrdersTotal()-1; i >= 0 ; i --){ Nerd Trader 2021.10.18 23:42 #16818 Aleksei Stepanenko #:the loop is not set correctly: it should be like this: Yes! It works! But why earlier still entered the second for loop and if I insert next line Print() - it will be executed (infinitely) but will not go further? Thanks anyway, now I can at least go to sleep. Infinite loop Trapping an Abnormal termination/timeout Errors, bugs, questions Nerd Trader 2021.10.18 23:44 #16819 Vitaly Muzichenko #:I wonder! Why? Why this, what sacred meaning does it have? --- You're searching by number, so search by number. If you have 2 warrants, he'll go through them, but he can't find the 3rd, or the 23rd. --- You don't seem to be quite clear on the task, so that's the solution. It's just that the majik must be unique, i.e. it must not have a match with the others. Valeriy Yastremskiy 2021.10.19 08:23 #16820 Aleksei Stepanenko #:the loop is not set correctly: it should be like this: What's the difference? And isn't order numbering from zero rather than one? 1...167516761677167816791680168116821683168416851686168716881689...1965 New comment
Really?!))
Have you tried it?
I've had the colour change working that way for a long time, but not on the line, although it should make no difference
PS. Looked at my other code, it changes the colour of the line there
I've had a colour change working that way for a long time, but not on the line, although it should make no difference
PS. Looked at my other code, it changes the colour of the line
Changes the whole line, not the desired section
Changes the whole line, not the right section
Well, he wrote that you have to change the whole line
So, I've adapted the code for the test, try running it and you get an infinite loop on the second order :(
I wonder! Why?
Why this, what sacred meaning does it have?
---
You're searching by number, so search by number.
If you have 2 warrants, he'll go through them, but he can't find the 3rd, or the 23rd.
---
You don't seem to be quite clear on the task, so that's the solution.
the loop is not set correctly:
it should be like this:
the loop is not set correctly:
it should be like this:
I wonder! Why?
Why this, what sacred meaning does it have?
---
You're searching by number, so search by number.
If you have 2 warrants, he'll go through them, but he can't find the 3rd, or the 23rd.
---
You don't seem to be quite clear on the task, so that's the solution.
the loop is not set correctly:
it should be like this:
What's the difference? And isn't order numbering from zero rather than one?