Download MetaTrader 5
To add comments, please log in or register
How to test a program before buying?
neverman
89
neverman 2015.10.30 13:25 

Hello guys,


I got puzzle for you that can't solve.

A last several orders were requoted by my broker. Their explanation is that my orders come with old prices, thats why slippage does not work and order is requoted.


I'm checking every 1 ms the broker quotes with Refreshrate() and MarketInfo, send the orders with MarketInfo data and I have 2 ms latency to my broker.


Can you tell me some possible reason, my orders to reach the MT4 server with old quotes ?

qjol
3243
qjol 2015.10.30 13:30  
show the relevant code, and someone may assist you
neverman
89
neverman 2015.10.30 13:51  
int Begin=GetTickCount();
   while(GetTickCount()<Begin+
13000)
   {
      Sleep(1);
      RefreshRates();
     
      int StartOrder=GetTickCount();


    //calculations not related to ordering

      if (Conditions)
         {
            Alert("Order 8001-BUY GOLD "," Buy Price=", MarketInfo("GOLD",MODE_ASK));
            FirstOrderAsk = MarketInfo("GOLD",MODE_ASK);
            _Order = OrderSend("GOLD",0,LotsGold,MarketInfo("GOLD",MODE_ASK),GoldSlippage,MarketInfo("GOLD",MODE_ASK)-MarketInfo("GOLD",MODE_POINT)*300,0,"",8001);
           
            err = GetLastError();
            while (!exit_loop)
                 {
                 RefreshRates();
               if (
                    !exit_loop &&
                    FirstOrderAsk != MarketInfo("GOLD",MODE_ASK) &&
                    Conditions
                  )                 
                       {
                           FirstOrderAsk = MarketInfo("GOLD",MODE_ASK);
                           _Order = OrderSend("GOLD",0,LotsGold,MarketInfo("GOLD",MODE_ASK),GoldSlippage,MarketInfo("GOLD",MODE_ASK)-MarketInfo("GOLD",MODE_POINT)*300,0,"",8001);
                           err = GetLastError();
                       }
               if (
                    !exit_loop &&
                    !Conditions
                  )                 
                    {
                       exit_loop = true;
                       Alert(Exit ordering! Ask=",MarketInfo("GOLD",MODE_ASK));
                    } 
                      
                    switch (err)
                        {
                            case ERR_NO_ERROR:
                                exit_loop = true;
                                Alert("GOLD Executed Buy Price=", MarketInfo("GOLD",MODE_ASK), " for ",GetTickCount()-StartOrder," ms" );
                                break; //Order executed successfully, break cycle
                           
                            case ERR_REQUOTE:
                                Alert("GOLD BUY Order REQUOTED! Lost time was ",GetTickCount()-StartOrder," ms" );
                                Sleep(1);
                                continue;    // continue until there is no error
                               
                        }  // end switch
                    } //while
                     

            RefreshRates();
         }
Keith Watford
Moderator
7875
Keith Watford 2015.10.30 20:55  

Do you run this on the Gold chart?

Is Gold open in the Market watch window? 

What code are you using, the above code will not compile

            Alert(Exit ordering! Ask=",MarketInfo("GOLD",MODE_ASK));

 missing "

 

Please use the SRC button when posting code 

neverman
89
neverman 2015.10.30 21:04  

sorry, I'm using the forum rarely. I missed SRC button :(

Yes, Gold is opening in Market watch window.

In Alert there is missing " because the original text was on other language and missed the "

whroeder1
13596
whroeder1 2015.10.30 22:08  
What is GoldSlippage?
neverman
89
neverman 2015.10.31 07:36  
200 ... but the support told me that the order is requoted because it comes with old price and slippage is irrelevant in this case.
/
To add comments, please log in or register