Automated Trading Championship 2007: common mistakes in experts - page 6

 
The error message "OrderModify error 1" means that OrderModify has been called with unchanged parameters, which is due to inaccurate programming.

Before calling OrderModify, check if you are calling the update with the new data or if you are trying to set existing values.
 
Your expert's test has been completed. Expert test report:
-----------------------
2007.09.08 17:47
on EURUSD:60
17:38:34 2007.01.04 00:01 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:02 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:03 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:04 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:04 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:06 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:06 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:06 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:06 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:06 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:06 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:07 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:07 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:07 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:07 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:07 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:07 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:07 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:07 stalker_2 EURUSD,H4: OrderModify error 1
17:38:34 2007.01.04 00:08 stalker_2 EURUSD,H4: OrderModify error 1
0 min 49 seconds
Errors: 20


-----------------------

Please correct your Expert Advisor code and upload a new version to your profile page:

I think your robot has gone crazy, it seems it has a lot of participants :-) It has already mixed up Expert Advisors. I've got an Expert Advisor that does not write "stalker_2" in comments and works on hourly chart. And the OrderModify command does not use it at all.
 
Renat:
The error message "OrderModify error 1" means calling OrderModify with unchanged parameters, which is due to inaccurate programming.

Before calling OrderModify, please check if you are calling the update with new data or if you are trying to set already existing values.

maybe you mean the construction ?

if ( RefreshRates() == true )

{

....

OrderModify(Ticket,...

}

in my trawl

Resresh() after each order modification in the loop

Breakeven after 35 pips profit

external variables, smallest value

FirstTralStopSell = 35;

subsequent trall after reaching 50 pips

i do not quite understand how this error can occur - i have no such error on tests

it is possible that after issuing the OrderModify command, the testing system emulates requotes in such a way that the price has time to return by more than 50 pips

but then how to avoid such a situation?

besides my LOGS do not show up in the log file given out by the testing system!

if (err != 0 )
{
if ( ECHOerror == 1 )
Print("Error("+err+") Open="+OrderOpenPrice()+""+OrderStopLoss()+" modifying SL: "+(Ask+Point*FirstTralStopSell)+" TP "+(0)+""+msgErrors(err));
}

void TralYZ(int lLockTralSell, int lLockTralBuy)
{
   int err;
   int cnt=OrdersTotal();
   int LocalDinamicTrallSELL;
   int LocalDinamicTrallBUY;
   int FirstTralStopSell;
   int FirstTralStopBuy;
   LocalDinamicTrallSELL = oDinamicTrallSELL ; // значения по умолчанию 
   LocalDinamicTrallBUY =  oDinamicTrallBUY  ;
   FirstTralStopSell = oFirstTralStopSell;             // первый безуюыток 
   FirstTralStopBuy = oFirstTralStopBuy;
 
 
   while(cnt>=0)
   {
      RefreshRates();
      
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      Sleep(10000);
      int Ticket=OrderTicket();
      int IDorder;
      IDorder = FindID(Ticket);
      if (OrderSymbol() == Symbol() )
      {
         if (OrderType()==OP_SELL && lLockTralSell == 0 ) 
         {         
            if ( OrderMagicNumber() == MAGIC3 )
               FirstTralStopSell = d3FirstTralStopBuy;
            if ( OrderMagicNumber() == MAGIC2 )
               FirstTralStopSell = d2FirstTralStopBuy;
            if ( OrderMagicNumber() == MAGIC1 )
               FirstTralStopSell = d1FirstTralStopBuy;
            if ( OrderMagicNumber() == cMAGIC3 )
               FirstTralStopSell = c3FirstTralStopSell;
            if ( OrderMagicNumber() == cMAGIC2 )
               FirstTralStopSell = c2FirstTralStopSell;
            if ( OrderMagicNumber() == cMAGIC1 )
               FirstTralStopSell = c1FirstTralStopSell;
            if ( 
               ( OrderStopLoss() == 0  && ( OrderOpenPrice()-Ask )>=(FirstTralStopSell*Point) + Ask-Bid ) ||
               ( OrderStopLoss() > OrderOpenPrice()  && ( OrderOpenPrice()-Ask )>=(FirstTralStopSell*Point) + Ask-Bid ) 
               )
            {                  
               if ( DEBUG == 1 )
                  Print( "1 SL="+OrderStopLoss()+" > OP="+OrderOpenPrice() +" && ( OP"+OrderOpenPrice()+" - Ask"+Ask+") "+( OrderOpenPrice()-Ask ) +" >= ( "+FirstTralStopSell+" *  "+Point+")  "+Ask+" - "+Bid+" ="+(Ask-Bid));
               lotlib_PrevLots = OrderLots();  
               lotlib_PrevProfit = OrderProfit();
               OrderModify(Ticket,OrderOpenPrice(),Ask+(Point*FirstTralStopSell) , 0 ,0,Purple);
               Sleep( 10000 );
               err=GetLastError();
               if (err != 0 )
               {
                  if ( ECHOerror == 1 )
                     Print("Error("+err+") Open="+OrderOpenPrice()+" "+OrderStopLoss()+" modifying SL: "+(Ask+Point*FirstTralStopSell)+" TP "+(0)+" "+msgErrors(err));
               }
            }
 
I have checked the same Expert code three times . the first two times there were no errors and the third time there was suddenly an error and I now have to change the Expert code. it is not clear why the same Expert code needs to be checked several times?
 
Renat:
The error message "OrderModify error 1" means OrderModify was called with unchanged parameters, which is due to inaccurate programming.

Before calling OrderModify, check if you are calling the update with new data or if you are trying to set existing values.


After introducing the construct

                     if ( RefreshRates() == true )
                        OrderModify(Ticket,OrderOpenPrice(),Bid-Point*LocalDinamicTrallBUY , 0,0,Purple);

terminal version 208 does not work at all in tests

RefreshRates() == true ?

LocalDinamicTrallBUY = 50;

entry to trall

              if ( OrderStopLoss() > OrderOpenPrice() && ( Bid - OrderStopLoss() )  >= (LocalDinamicTrallBUY*Point) + Ask-Bid )
                  {
                     lotlib_PrevLots = OrderLots();  
                     lotlib_PrevProfit = OrderProfit();
                     if ( RefreshRates() == true )
                        OrderModify(Ticket,OrderOpenPrice(),Bid-Point*LocalDinamicTrallBUY , 0,0,Purple);

there must be some subtleties... I don't know about

 
YuraZ:
Renat:
The error message "OrderModify error 1" means OrderModify is called with unchanged parameters, which is due to inaccurate programming.

Before calling OrderModify, check if you're calling the update with new data or if you're trying to set existing values.

maybe you mean the construction ?


This means that you are trying to set the same StopLoss value in OrderModify that was already there. For example, if the StopLoss is 1.3020 and you try to set the stop again at 1.3020, OrderModify will return code 1. This is explicitly stated in OrderModify documentation:

bool OrderModify( int ticket, double price, double stoploss, double takeprofit, datetime expiration, colour arrow_color=CLR_NONE)
Changes the parameters of previously opened positions or pending orders. Returns TRUE if the function completes successfully. Returns FALSE if the function fails. You must call GetLastError() to get the error information.

Note: The open price and expiration time can only be changed for pending orders.
If unchanged values are passed as parameters to the function, an error 1 (ERR_NO_RESULT) will be generated.
On some trade servers, a ban on expiry of pending orders may be set. In this case an error 147 (ERR_TRADE_EXPIRATION_DENIED) will be generated when trying to set a non-zero value in the expiration parameter.
 
Renat:
YuraZ:
Renat:
The error message "OrderModify error 1" means an OrderModify call with unchanged parameters, which is due to inaccurate programming.

Before calling OrderModify, check if you are calling the update with new data or if you are trying to set already existing values.

maybe you mean the construction ?


What is meant is that you are trying to set the same StopLoss value in OrderModify that was already there. For example, if the StopLoss is 1.3020 and you try to set the stop again at 1.3020, OrderModify will return code 1. This is explicitly stated in OrderModify documentation:

bool OrderModify( int ticket, double price, double stoploss, double takeprofit, datetime expiration, color arrow_color=CLR_NONE)
Modifies parameters of previously opened positions or pending orders. Returns TRUE if the function completed successfully. Returns FALSE if the function fails. Call GetLastError() to get information about the error.

Note: The open price and expiration time can only be changed for pending orders.
If unchanged values are passed as parameters to the function, an error 1 (ERR_NO_RESULT) will be generated.
On some trade servers, a ban on expiry of pending orders may be set. In this case an error 147 (ERR_TRADE_EXPIRATION_DENIED) will be generated when trying to set a non-zero value in the expiration parameter.


WOW!!! exactly!!! Renat thanks!

added trall entry condition

&& OrderStopLoss() != Ask+Point*LocalDinamicTrallSELL

if ( 
                         OrderStopLoss()  < OrderOpenPrice()
                      && ( OrderStopLoss()-Ask )>=(LocalDinamicTrallSELL*Point) + Ask-Bid   
                      && OrderStopLoss() !=  Ask+Point*LocalDinamicTrallSELL    
                       ) 
                  {                     
                     if ( DEBUG == 1 )
                        Print( "2 SL="+OrderStopLoss()+" < OP="+OrderOpenPrice() +" && ( OP"+OrderOpenPrice()+" - Ask"+Ask+") "+( OrderOpenPrice()-Ask ) +" >= ( "+LocalDinamicTrallSELL+" *  "+Point+")  "+Ask+" - "+Bid+" ="+(Ask-Bid));
                     lotlib_PrevLots = OrderLots();  
                     lotlib_PrevProfit = OrderProfit();
                     if ( RefreshRates() == true )
                        OrderModify(Ticket,OrderOpenPrice(),Ask+Point*LocalDinamicTrallSELL , 0,0,Purple);
                     err=GetLastError();
                     if (err != 0 )
                     {   
                        if ( ECHOerror == 1 )
                           Print("Error("+err+") Open="+OrderOpenPrice()+" "+OrderStopLoss()+" modifying SL: "+(Ask+Point*LocalDinamicTrallSELL)+" TP "+(0)+" "+msgErrors(err));
                     }
                  }

But there were no errors in my logs during testing! - this is very strange

 
pilgrim:

I think your robot has gone crazy, I think it has a lot of participants :-) It has already started to confuse EAs. My EA does not write "stalker_2" in the comments, it works on the hourly chart. And the OrderModify command does not use it at all.
The automated tester's script has captured someone else's logs - has already been fixed.
 
i.e. twice I've been emailed that the expenrt has passed the test and I'm registered... and on the third one it says I have an error in the code... why do i have to change the code of the expert i uploaded it to the profile once?
 
folver:
i.e. twice i have been emailed that the exponent has passed the test and i am registered... and the third time it says I have an error in the code... why should I change the code of the Expert Advisor once I have uploaded it to the profile?
Judging by the results, the Expert Advisor has caught a margin call. I cannot say anything yet. Tomorrow morning the next checks will be completed and we will check the results.
Reason: