problematic again

 

Hi

I am wondering what is going on with my TP level with this ea I'm programming

it returns me a tp error on the ordermodify sequence here is the code

double takeprofit = 25;
double stoploss = 50;

double sl;
double sldistance;
double tp;
double tpdistance;

// within init
      if(Digits==5)
         {
            Multi=10;
            ATRMultiple=10000;
         } 
      if(Digits==3)
         {
            Multi=10;
            ATRMultiple=100;
         }
      if(Digits==4)
         {
            Multi=1;
            ATRMultiple=1000;
         } 
      if(Digits==2)
         {
            Multi=1;
            ATRMultiple=10;
         }

// other function block

void OpenABuy()
   {
      if (Money_Management == true)
         {
            Free = AccountBalance();
            lot=MathFloor(Free*Percent/100/onelot/step)*step;
            if (lot < minlot) lot = minlot;
               }
      if (Money_Management == false)
         {
            lot = Manual_Lots;
            if (lot < minlot) lot = minlot;
         }
      while (ticket == -1)
         {
            com = StringConcatenate(ea, " Version: ",version," ",hours,"h",minutes);
            ticket = OrderSend(Symbol(), OP_BUY, lot, MarketInfo(Symbol(), MODE_ASK), 30, 0, 0, com, Magic, 0);
            if( ticket > 0 )
               {
                  Print("Order Sucessfully Placed # ", ticket);
                  OrderSelect(ticket,SELECT_BY_POS,MODE_TRADES);
                     {
                        price = OrderOpenPrice();
                        sldistance = stoploss*Multi;
                        sl = price-sldistance;
                        tpdistance = takeprofit*Multi;
                        tp = price+tpdistance;
                     }
                  while (ordermodified == false)
                     {
                        ordermodified = OrderModify(ticket, price, sl*Point, tp*Point, 0,CLR_NONE);
                     }
               }            
            else
               {
                  Print("Order Send Unsucessfully With Error # ", GetLastError() );
                  break;
               }
         }
   }

I'm wondering if a normalizedouble woudl make it or if something obvious would affect this error

 
liquidd:

Hi

I am wondering what is going on with my TP level with this ea I'm programming

it returns me a tp error on the ordermodify sequence here is the code

I'm wondering if a normalizedouble woudl make it or if something obvious would affect this error

Where do you check that your modified order complies with this ? Requirements and Limitations in Making Trades
 
  1. What are Function return values ? How do I use them ? - MQL4 forum
  2. Where do you print the values of your variables
  3. sl = price-sldistance;   // A price like 1.34567
      
    ordermodified = OrderModify(ticket, price, sl*Point, tp*Point, 0,CLR_NONE);
      // price is wrong with ANY slippage ^^^  ^^^ a value like 0.0000134567 (0.1 pips)
  4. Don't use NormalizeDouble
Reason: