error code 131

 

I am so tired of strategy tester  error code 131 iv read too many topics which almost says it is du to wrong trade volume which could be fixed by normalizing the order's lot iv do that but fails tooooo!!

finally i found strange case that there was a ticket with no order matching on chart ,but how to avoid this in real trading??

wrong order

 
hadher ramadhan:

I am so tired of strategy tester  error code 131 iv read too many topics which almost says it is du to wrong trade volume which could be fixed by normalizing the order's lot iv do that but fails tooooo!!

finally i found strange case that there was a ticket with no order matching on chart ,but how to avoid this in real trading??


You are probably using imported tick data ?
 
Alain Verleyen:
You are probably using imported tick data ?

no sir it downloaded normally from Mt4 tab and it is fresh data

 
hadher ramadhan:

no sir it downloaded normally from Mt4 tab and it is fresh data

Then I am afraid nobody can help without more information about how to reproduce this problem.
 
Alain Verleyen:
Then I am afraid nobody can help without more information about how to reproduce this problem.

iv tried re download history data ,,,replace,,time frame, replace pair ,replace broker,and fail  i start dout about auto lot  code this is what i am using it is so simple 

//+------------------------------------------------------------------+
//| Automatical lot's calculating.                                   |
//+------------------------------------------------------------------+
double GetLots()
  {

   double lot=MathCeil(AccountFreeMargin()*Risk/1000)/100;
   if(lot<MarketInfo(Symbol(),MODE_MINLOT))
      lot=MarketInfo(Symbol(),MODE_MINLOT);
   if(lot>MarketInfo(Symbol(),MODE_MAXLOT))
      lot=MarketInfo(Symbol(),MODE_MAXLOT);

   return(lot);
  }
 
  1. Lot size must also be adjusted to a multiple of LotStep and check against min and max. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
  2. Risk is not a function of Free Margin.
    Risk depends on your initial stop loss, lot size, and the value of the pair.
    1. In code (MT4):
      1. You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
      2. Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
      3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
                  MODE_TICKVALUE is not reliable on non-fx instruments with many brokers.
      4. You must normalize lots properly and check against min and max.
      5. You must also check FreeMargin to avoid stop out
      Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5=0.1 Lots maximum.

    2. Use a GUI EA like mine (for MT4): Indicators: 'Money Manager Graphic Tool' indicator by 'takycard' Forum - Page 6