[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 611

 
lottamer:

please advise...what the hell...in its original form (withoutPlaySound("alert.wav");) - works. But if you add to any link in addition to the destination flag and some action (play music for example) ... then the flags are printing 0000 and the music is played at full speed! Please tell me where the error?

if(Stoch_1>Stoch_2) flag1=1 ;  
      {Print (flag1,flag2,flag3,flag4);
      
if(Stoch_1<Stoch_2 && flag1==1) flag2=1;
      {Print (flag1,flag2,flag3,flag4);

if ((Stoch_1>Stoch_2) && flag1==1 && flag2==1) flag3=1; 
      {Print (flag1,flag2,flag3,flag4)

Why are you comparing the same thing so many times in a row?
 

if(Stoch_1>Stoch_2) { flag1=1 ; Print (flag1,flag2,flag3,flag4); }


if(Stoch_1<Stoch_2 && flag1==1) flag2=1 ; Print (flag1,flag2,flag3,flag4); }

if ((Stoch_1>Stoch_2) && flag1==1 && flag2==1) {flag3=1; Print (flag1,flag2,flag3,flag4);PlaySound("alert.wav");}


if(Stoch_1<Stoch_2 && flag1==1 && flag2==1 && flag3==1) flag4=1;
{Print (flag1,flag2,flag3,flag4);}
if(Stoch_1>Stoch_2 && flag1==1 && flag2==1 && flag3==1 && flag4==1)
{OrderSend (Symbol( ), OP_SELL, 0.01 ,Bid, 0, 0, 0, NULL, 450, 0, CLR_NONE);
Print ("OUT");}



flag1=0;
flag2=0;
flag3=0;
flag4=0;

Understanding that you'll learn and for the sake of learning you write something... At least I've arranged your brackets in such a way that they play a role, in my opinion.

 
Dimka-novitsek:

Good afternoon! Please help me with order modification, i.e. the order selection cycle for its condition. I first find an order triggered at TakeProfit, it is a specific order with a tacket ticket. Thus, the loop fails about once out of ten, which is indicated by the difference of green and blue lines in the tester. And visualization - stop loss sometimes does not move.

In general, help, please!

Condition

if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
1 .Выполняется, если в истории термина нет ордеров, и продолжать цикл в таком случае не имеет смысла.
2. Чтобы найти ордер, сработавший именно по тейкпрофиту надо сравнить значение ТП со значением цены закрытия ордера
3.  Если вам нужен не любой ордер,закрытый по ТП, надо найти последний.
4. Еси в if(nahodka){if (OrderSelect(tucket,SELECT_BY_TICKET)) используется значение tucket, Выбранное в предыдущем цикле, ордер нельзя модифицировать, потому, что он уже закрыт. 
 

1.Executed if there are no orders in the terminal history and it does not make sense to continue the cycle in that case.

Thank you!!! That's where it's all going down. That's the problem!!! How did he even modify himself once in a while?

2. To find an order triggered exactly at Take Profit, we should compare the TP value with the close price of the order

I first select a certain order in the loop on the history and then I seem to compare it that way.

 
To translate the stock into a comment, rather than continue pasting the code, you need to at the end of the line ;?
 

if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue; In my loop, it is like this - if there are no orders in the terminal history, and it makes no sense to continue the loop in that case, then continue!

So it's like this, isn't it?

Wow, a riddle!!!

 
At the end of the string //comment-anything beyond the two slashes or whatever the compiler doesn't read.
 
Dimka-novitsek:

1.Executed if there are no orders in the terminal history and it does not make sense to continue the cycle in that case.

Thank you!!! That's where it's all going down. Oh my gosh! How did he even modify himself once in a while?

2. To find an order triggered exactly at Take Profit, we should compare the TP value with the close price of the order

I first select a certain order in the loop on the history and then I seem to compare it that way.


If a specific order, i.e. you know the ticket number, you don't need a cycle, just selectOrderSelect(ticket,SELECT_BY_TICKET, MODE_HISTORY)
 
Thank you!!! I'll give it a go!
 
Dimka-novitsek:

if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue; In my loop it is like this - if there are no orders in the term history, and it makes no sense to continue the loop in that case, then continue!

So it's like this, isn't it?

Wow, a riddle!!!


Thenbreak orreturn.continue; -- the cycle continuation operator.