[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 484

 

Incorrect parameters have been sent to the trade function, e.g. incorrect symbol, unidentified trade, negative price tolerance, non-existing ticket number, etc. You need to change the program logic.


Try the second parameter to put OrderOpenPrice() instead of zero

 
sergeev:

get in the habit of printing any parameters that may be relevant to the error.

if (!OrderModify(...)) { Print(GetlastError()+.... OrderModify parameter list ); }



Yes, it's a good habit. Thank you.))

FOReignEXchange 03.07.2011 18:35

Try the second parameter instead of zero to put OrderOpenPrice()

Yes, that's right. )) And for some reason I was convinced that you can't set parameters that you don't need to modify, as that will lead to another error. Is there something similar to what I'm talking about?

Something like this is fixed in my mind:

The function tries to change the parameter to the same value.

 
tol64:


And for some reason I was convinced that you can't set parameters that you don't want to modify, as that would cause another error. Is there something similar to what I'm talking about?

Something like this is fixed in the head:

The function tries to change the parameter to the same value.


You could change just one parameter and leave the rest unchanged and write OrderOpenPrice(), OrdsrStopLoss() etc. everywhere.
 
Hello! Does anyone have an example of a trawl from a certain price level with a certain step? Thank you!
 

Here's another question I have. On the code example I gave above (tol64 03.07.2011 18:20).

The program does not always synchronize the stop loss of different positions. That is, the position is selected, the condition is fulfilled, it is also recorded in the journal, but the stop loss is not modified.

In the picture above stop loss for position with ticket 4 should be modified and set to the same value as for position with ticket 1. The program reaches this point with the print, but further execution seems to be blocked.

   for(count = 0; count < OrdersTotal(); count++)
      {  
         if(OrderSelect(count,SELECT_BY_POS,MODE_TRADES)) 
            Print("Ticket: ",OrderTicket(),", Type: ",OrderType(),", Magic: ",OrderMagicNumber(),", StopLoss: ",OrderStopLoss());

         double Op_Price = NormalizeDouble(OrderOpenPrice(),Digits);
         double Stp_Loss = NormalizeDouble(OrderStopLoss(),Digits);
         
         if(OrderMagicNumber() == Magic_SP01)
            {  if(OrderType() == OP_SELLSTOP)
                  {  if(Low_1 < SP_Level_01 && new_val > Op_Price && new_val < Open_0)  
                        {  OrderModify(OrderTicket(),new_val,OrderStopLoss(),0,0,DeepPink);  }

                     if(!(global_trailing_SP < Stp_Loss && global_trailing_SP > High_1)) Print("Условие не выполняется!");  else
                        {  OrderModify(OrderTicket(),OrderOpenPrice(),global_trailing_SP,0,0,DeepPink);
                           Print("Условие ModifyOrder исполнилось: global_trailing_SP: ",global_trailing_SP,", Stop Loss: ",OrderStopLoss());  }
                  }
               if(OrderType() == OP_SELL)
                  {  if(global_trailing_SP < Stp_Loss && global_trailing_SP > High_1)  
                       {  OrderModify(OrderTicket(),OrderOpenPrice(),global_trailing_SP,0,0,DeepPink);  }
                  }
            }

         ...

Because the variant, in which the condition is not fulfilled, is not logged either. Tried so many different combinations, but none of them worked. Please help.

 

And here.

 if(OrderSelect(count,SELECT_BY_POS,MODE_TRADES)) 

Isn't that the way to do it?

 if(OrderSelect(count,SELECT_BY_POS,MODE_TRADES)=true) 
 
FOReignEXchange:

And here.

Isn't that the way to do it?


No, it doesn't. It returns a bool anyway.
 
tol64:

Here's another question I have. On the code example I gave above (tol64 03.07.2011 18:20).

The program does not always synchronize the stop loss of different positions. That is, the position is selected, the condition is fulfilled, it is also recorded in the journal, but the stop loss is not modified.

In the picture above stop loss for position with ticket 4 should be modified and set to the same value as for position with ticket 1. The program reaches this point with the print, but further execution seems to be blocked.

Because the variant, in which the condition is not fulfilled, is not logged either. Tried so many different combinations, but none of them worked. I would like your help.


Print() to output the value of variable global_trailing_SP directly in the function you provide.

Where do you read the value of this variable?

And replace zero (highlighted) in the code

OrderModify(OrderTicket(),OrderOpenPrice(),global_trailing_SP,0,0,DeepPink)

To OrderTakeProfit()

 
FOReignEXchange:

What is this condition for then, if there is no condition? And the order data are then not used.


Then tell me which code is better

if(OrderSelect(count,SELECT_BY_POS,MODE_TRADES)) 

write it down as:

if(!OrderSelect(count,SELECT_BY_POS,MODE_TRADES)) continue;
 
abolk:


then and tell me what the better code is

write it down as:


I don't understand? I'm just looking in the help, there OrderSelect() uses a condition. I haven't seen anywhere without true.

If is a condition operator. And there should be a condition in brackets. It seems more logical to me this way. Although there may be no difference.