Reply

SQ 3.8.0 Error 129 invalid price in real trading

14 replies

mikeyc

Customer, bbp_participant, community, 877 replies.

Visit profile

9 years ago #113353

Hi Mark,

 

I’ve created, tested and exported the MQL4 for a strategy that looks promising on EURUSD H1 timeframe.  It uses the reverse market position option, but fails when forward testing on a real account:

 

2015.02.16 17:59:59.599    Strategy 9.7 EURUSD,H1: 2015.02.16 20:00:09 Error opening order: 129 : invalid price
2015.02.16 17:59:59.599    Strategy 9.7 EURUSD,H1: 2015.02.16 20:00:09 Opening order, direction: 0, price: 1.13572, Ask: 1.13572, Bid: 1.13548
2015.02.16 17:59:55.489    Strategy 9.7 EURUSD,H1: 2015.02.16 20:00:05 Error opening order: 129 : invalid price
2015.02.16 17:59:55.489    Strategy 9.7 EURUSD,H1: 2015.02.16 20:00:05 Opening order, direction: 0, price: 1.13572, Ask: 1.13572, Bid: 1.13548
2015.02.16 17:59:52.067    Strategy 9.7 EURUSD,H1: 2015.02.16 20:00:01 Error opening order: 129 : invalid price
2015.02.16 17:59:52.067    Strategy 9.7 EURUSD,H1: 2015.02.16 20:00:01 Opening order, direction: 0, price: 1.13572, Ask: 1.13572, Bid: 1.13548
2015.02.16 17:59:52.052    Strategy 9.7 EURUSD,H1: close #164716296 sell 0.10 EURUSD at 1.14383 at price 1.13572

 

Any idea why the EA does not appear to be able to open the opposite trade direction after closing a trade?

 

Thanks,

 

Mike

0

mikeyc

Customer, bbp_participant, community, 877 replies.

Visit profile

9 years ago #128868

Mark,

 

Looking at the trading logic in the generated EA, it looks to me like it retries regardless of the cause of the error, and in the case of error 129 it should refresh the bid/ask as the price has moved beyond the slippage.

 

See http://forum.mql4.com/61528

 

 

For my own EA’s I use a library called OrderReliable to handle the tricky error handling required. 

 

https://github.com/keyguy/TradersTech/blob/master/OrderReliable_2011.01.07.mqh

 

Maybe include this in the next version of the SQ template for MQ4?

 

Regards,

 

Mike

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

9 years ago #128890

thanks for letting me know about this error and library, I’ll look at it.

Mark
StrategyQuant architect

0

mikeyc

Customer, bbp_participant, community, 877 replies.

Visit profile

8 years ago #129627

I’m seeing the slippage error quite a lot with certain brokers (hello FXDD :angry: ).  I think the best solution is to avoid these brokers with bad slippage.

0

geektrader

Customer, bbp_participant, community, 522 replies.

Visit profile

8 years ago #129666

Go with a ECN broker, that error is a typical market maker broker thing in that they refuse to accept your order at the price they show in MT4. It´s called requotes and those are there to make the broker more gains from your losses:) This will never happen on a good and honest ECN broker. There are many of those, my recommendation is Global Prime in Australia.


🚀 Unlock Your Edge in Automated Forex Strategy Development 🚀

Historical Forex Data Starting From 1987, 28 Pairs, M1, 99% Error-Free, Lifetime Free Updates

0

Matusiak Adrian

Customer, bbp_participant, community, 300 replies.

Visit profile

8 years ago #129687

This will never happen on a good and honest ECN broker.

 

You’re wrong… There are many other things that occurs requotes. Simply, try to make trade without requotes with ping to trading server > 300ms. Even with honest broker You will never get that price what You see, because this price already doesn’t exist. 

btn_viewmy_160x33.png

0

geektrader

Customer, bbp_participant, community, 522 replies.

Visit profile

8 years ago #129701

Sure, but that´s not requote, that is slippage and won´t throw an error at the EA like a requote does – the trade will be opened in any case, just with a slipped price. I still prefer that compared to requotes. Btw, it´s clear that you shouldn´t have a 300 ms ping to the brokers server. I am working for a ECN broker btw., and even for small accounts you should rent a VPS to run your strategies.


🚀 Unlock Your Edge in Automated Forex Strategy Development 🚀

Historical Forex Data Starting From 1987, 28 Pairs, M1, 99% Error-Free, Lifetime Free Updates

0

Matusiak Adrian

Customer, bbp_participant, community, 300 replies.

Visit profile

8 years ago #129704

even for small accounts you should rent a VPS to run your strategies.

 

Totally AGREE.

btn_viewmy_160x33.png

0

Dan

Customer, bbp_participant, community, 31 replies.

Visit profile

8 years ago #133511

Hi Mark,

 

I’m getting the same error as MickeyC in which some times when my AE  goes to place a trade I get the “Error opening order 129: invalid price”  It retires 3 more times with the original price. Is there some code to refresh the price when it tries to replace the order that I can insert and is this something SQ4 will address.

 

Thanks for your help

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

8 years ago #133524

Dan,

 

can you upload that strategy or send it to [email protected]?

0

Dan

Customer, bbp_participant, community, 31 replies.

Visit profile

8 years ago #133528

Hi Thomas,

 

I prefer not to share my AE and trouble shoot it from the stand point that this is a SQ logic issue, where it should refresh the price as it has moved past the slippage amount.  MIckeyC pointed this out on this thread earlier and Mark was going to look into it.  Please see above, has Mark made any changes to fix this error in the next issue of SQ?  I followed the link MickeyC provided MQL4 site  http://forum.mql4.com/61528 and it says to fix error code 129 invalid price, to place RefreshRates(); before order send.  I’m not a programmer in any way at best I tried to insert that into the AE.  In bold towards the bottom is where I added the refresh rate code, not sure if this will work, this is where I would need your expertise. I will say I’ve only had the error happen twice and it retries to place the order 3 times afterwards with each time non sucessfull invalid price error129, I’m hoping by adding the RefreshRate code in there that it’ll fixes this issue. 

 

Thanks for your help

 

 // open order with error handling and retries
   int ticket = 0;
   int retries = 3;
   while(true) {
      retries–;
      if(retries < 0) return;
      if(getMarketPosition() != 0) return;

      if(sqIsTradeAllowed() == 1) {
         ticket = openOrderWithErrorHandling(orderType, orderLots, openPrice, stopLoss, profitTarget, comment, MagicNumber);
         if(ticket > 0) {
            if(tradeDirection > 0) {
                ObjectSetText(“lines”, “Last Signal: Long, ticket: “+ticket, 8, “Tahoma”, LabelColor);
            } else {
                ObjectSetText(“lines”, “Last Signal: Short, ticket: “+ticket, 8, “Tahoma”, LabelColor);
            }
            return;
         }
      }

      if(ticket == -130 || ticket == -129) {
         // invalid stops or volume, we cannot open the trade
         return;
      }

      Sleep(1000);
     
   }
   return;
}

//+——————————————————————+

int openOrderWithErrorHandling(int orderType, double orderLots, double openPrice, double stopLoss, double profitTarget, string comment, int magicNumber) {

   //—————————————
   // send order
   int error, ticket;
   Log(“Opening order, direction: “, orderType,”, price: “, openPrice, “, Ask: “, Ask, “, Bid: “, Bid);
   ticket = OrderSend(Symbol(), orderType, orderLots, openPrice, MaxSlippage, 0, 0, comment, magicNumber, 0, Green);
   if(ticket < 0) {
      // order failed, write error to log
      error = GetLastError();
      Log(“Error opening order: “,error, ” : “, ErrorDescription(error));
      return(-error);
      Sleep(1000);
      //—refresh price data  
      RefreshRates();

    
   }

   rettmp = OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES);
   Log(“Order opened: “, OrderTicket(), ” at price:”, OrderOpenPrice());

   stopLoss = getSpecialSL(stopLoss);
   profitTarget = getSpecialPT(profitTarget);

   if(EmailNotificationOnTrade) {
      SendMail(“GB Strategy – Order opened”, getNotificationText());
   }

0

Dan

Customer, bbp_participant, community, 31 replies.

Visit profile

8 years ago #133543

Hi Tomas I need your Intellect and guidance on the above issue I have.

0

Dan

Customer, bbp_participant, community, 31 replies.

Visit profile

8 years ago #133561

Thomas am I not going to get a response????

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

8 years ago #133566

sorry for late answer. Unfortunately it is not that simple, because the price of a trade is set some time before this function is called, also for market orders.

But you can add the following piece of code just after the call of sqIsTradeAllowed().

It will refresh market price just before the order is sent.

 

 

   …
   // open order with error handling and retries
   int ticket = 0;
   int retries = 3;
   while(true) {
      retries–;
      if(retries < 0) return;
      if(getMarketPosition() != 0) return;
 
      if(sqIsTradeAllowed() == 1) {
         
         if(orderType == OP_BUY || orderType == OP_SELL) {
            RefreshRates();
            openPrice = NormalizeDouble(getTradeOpenPrice(tradeDirection), Digits);
         }
 
         ticket = openOrderWithErrorHandling(orderType, orderLots, openPrice, stopLoss, profitTarget, comment, MagicNumber);
         if(ticket > 0) {
            if(tradeDirection > 0) {
                ObjectSetText(“lines”, “Last Signal: Long, ticket: “+ticket, 8, “Tahoma”, LabelColor);
            } else {
                ObjectSetText(“lines”, “Last Signal: Short, ticket: “+ticket, 8, “Tahoma”, LabelColor);
            }
            return;
         }
      }

 

 

Mark
StrategyQuant architect

0

Dan

Customer, bbp_participant, community, 31 replies.

Visit profile

8 years ago #133576

Hi Mark,

Thanks for responding, I’ll add the snippet of code and see if that works…….. Thanks again

0

Viewing 14 replies - 1 through 14 (of 14 total)