Error problems with OrderSend function

Back to topics list To post a new topic, please log in or register
avatar
9
Deyaz 2016.06.28 10:53
 

Hello all, 

 

I am struggeling with an error I constantly get from the order execution.

 

double BidPrice = NormalizeDouble(Bid, Digits);
double SellingPrice = ( BidPrice-(TP/100*1.01) ); 
      
      
      result = OrderSend(Symbol(), OP_SELLSTOP,
                         AdvancedMM(),
                         NormalizeDouble(SellingPrice, Digits),
                         Slippage,
                        // SL,
                         //NormalizePrice((TP), Digits),
                         NormalizeDouble(SL, Digits), 
                         NormalizeDouble(TP, Digits),
                         "RELATIVITY_1.0 v"+versionnr,
                         MagicNumber, 
                         (TimeCurrent()+(60*60*1.5)), 
                         Red
        );


The order is being executed, but then MT4 does not react anymore (so far I always cancelled further backtests as I doubt there will be any reactions anymore). The error I get as well is error 0.  

Also if I replace BidPrice by Bid only, there is no change. 

If I change the SellingPrice variable to the following: 

 

double SellingPrice =  Bid-(TP*0.4); 

I receive error #130.  

 

On the live testing I received error #3 today with the following code:

 

result = OrderSend(Symbol(), OP_SELLSTOP,
                         AdvancedMM(),
                         NormalizeDouble(( BidPrice-(TP/100*1.01) ), Digits),
                         Slippage,
                        // SL,
                         //NormalizePrice((TP), Digits),
                         NormalizeDouble(SL, Digits), 
                         NormalizeDouble(TP, Digits),
                         "RELATIVITY_1.0 v"+versionnr,
                         MagicNumber, 
                         (TimeCurrent()+(60*60*1.5)), 
                         Red
        );

 

 

Does anyone have any idea?

 

 

 

 

avatar
1200
FMIC 2016.06.28 11:26 #
 
  1. The code you supplied is insufficient to be able to test and recreate the conditions that cause the problems mentioned.
  2. One clue, is that you mention error 130, which could indicate that you are not testing for the Minimum Stop conditions set by your broker, namely the MODE_STOPLEVEL size (check MODE_FREEZELEVEL too).
  3. Another, clue is that you are using the Bid price to calculate the Take-Profit (and maybe even the Stop-Loss) on a SELL_STOP order, but a Sell order will close at the Ask price, meaning you are not compensating for spread.
  4. One more clue, is error 3, which means that there are invalid parameters like volume or opening price:
    1. For the Opening Price and stops, remember that Buy orders open at Ask and close at Bid, while Sell orders open at Bid and Close at Ask. Also make sure the prices are aligned with the tick size (MODE_TICKSIZE). Don't just "NormalizeDouble()" without understanding the ramifications (search here on the forum as there is plenty of debate on that issue).
    2. For Volume, always check the market variables to make sure your parameters are valid, such as MODE_MINLOT, MODE_MAXLOT, MODE_LOTSTEP.
avatar
12985
WHRoeder 2016.06.28 13:23 #
 
Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
Back to topics list  

To add comments, please log in or register