Download MetaTrader 5
To add comments, please log in or register
Publish your article to let the traders see it in MetaTrader 5!
highcloud
155
highcloud 2013.08.08 20:46 

Hi

I got a very well running EA on EURUSD with decent profits. But the thing is, as soon as i change to - say - USDJPY, i get a lot of [Invalid Price] errors.

Anybody got any idea why it wont work on other currencies, even though i programmed it for all currencies?

//--- set orders
   if(PositionsTotal()<1 && OrdersTotal()<1)
     {
      if(signal())
        {
         request.action = TRADE_ACTION_PENDING;
         request.symbol = _Symbol;
         request.volume = NormalizeDouble(volume(),2);
         request.price=NormalizeDouble(Ask+StopLevel*_Point,_Digits);
         request.sl = NormalizeDouble(request.price - SL*_Point,_Digits);
         request.tp = NormalizeDouble(request.price + TP*_Point,_Digits);
         request.deviation=10;
         request.type=ORDER_TYPE_BUY_STOP;
         request.type_filling=ORDER_FILLING_FOK;
         Print("Tickvolume: ",Ticks[0]);
            OrderSend(request,result);
            if(result.retcode==10009 || result.retcode==10008)
             {  Print("BuyStop order set");
                }
            else
              {
               Print(ResultRetcodeDescription(result.retcode));
               return;
              }
         
        }
.......

//--- move the order  
 for(int pos=0; pos<OrdersTotal(); pos++)
     {
      ulong order_ticket=OrderGetTicket(pos);
      if(OrderGetString(ORDER_SYMBOL)==Symbol())
        {
         if(OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_BUY_STOP)
           {
            if(OrderGetDouble(ORDER_PRICE_OPEN)-Ask>20*_Point)
              {
               request.action= TRADE_ACTION_MODIFY;
               request.order = order_ticket;
               request.price = NormalizeDouble(Ask+20*_Point,_Digits);
               request.sl = NormalizeDouble(request.price - SL*_Point,_Digits);
               request.tp = NormalizeDouble(request.price + TP*_Point,_Digits);
               OrderSend(request,result);
               if(result.retcode==10009 || result.retcode==10008)
                 Print("BuyStop order modified");
               else
                 {
                  Print(ResultRetcodeDescription(result.retcode));
                  return;
                 }
              }
           }
Files:
Alain Verleyen
Moderator
29594
Alain Verleyen 2013.08.08 21:00  
highcloud:

Hi

I got a very well running EA on EURUSD with decent profits. But the thing is, as soon as i change to - say - USDJPY, i get a lot of [Invalid Price] errors.

Anybody got any idea why it wont work on other currencies, even though i programmed it for all currencies?

What is the value of STOPLEVEL for this currency ?
highcloud
155
highcloud 2013.08.08 22:46  

The Picture is from the strategy tester with USDJPY. StopLevel for USDJPY is 28 points. On EURUSD its 18 points.

Alain Verleyen
Moderator
29594
Alain Verleyen 2013.08.08 22:55  
highcloud:

The Picture is from the strategy tester with USDJPY. StopLevel for USDJPY is 28 points. On EURUSD its 18 points.

You are using

               request.price = NormalizeDouble(Ask+20*_Point,_Digits);

when modifying your order so it's to close to market price (<28).

For the creation of the order maybe you can print the value of Ask and Stoplevel variables to check the values.

/
To add comments, please log in or register