Invalid Price help

 

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:
 
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 ?
 

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

 
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.

Reason: