Download MetaTrader 5

Help with Invalid Stops pleae

To add comments, please log in or register
Sign up for to post your Forum topic
Arthur Ockwell
Arthur Ockwell 2016.03.22 13:28 


I calculate my trade parameters as follows:


Print(DisplayTimeStr," [",Symbol(),"] Time ["+LondonDate+" "+LondonTime+"]",
                                       " BuyOrSell '",BuyOrSell,"' entry ", DoubleToString(entry,Digits)," TP ",DoubleToString(tp,Digits),
                                       " SL ",DoubleToString(sl,Digits)," Ask ",DoubleToString(Ask,Digits)," Bid ", DoubleToString(Bid, Digits)); 

The -20.0 on the entry price is to ensure that I am not too close to the Bid price, in reality this will be set to 2.0. Trade is triggered immediately on candle close, so I think I can get away with this.

Here is the code around OrderSend, I have put in extra tracing in an attempt to find the problem!

    Print(DisplayTimeStr," [",Symbol(),"] Time ["+LondonDate+" "+LondonTime+"]",
                                       " TypeOfOrderReqd '",TypeOfOrderReqd,"' entry ", entry,
                                       " Ask ",DoubleToString(Ask,Digits)," Bid ", DoubleToString(Bid, Digits)); 


and here is what I find in the Journal when using Strategy Tester:

GER30(£),M1: 18/03/16 10:57 [GER30(£)] Time [21.03.2016 07:10] BuyOrSell 'Sell' entry 9889.7 TP 9869.7 SL 9909.7 Ask 9913.0 Bid 9910.7
GER30(£),M1: 18/03/16 10:57 [GER30(£)] Time [21.03.2016 07:10] TypeOfOrderReqd 'Sell' entry 9889.700000000001 Ask 9913.0 Bid 9910.7
GER30(£),M1: OrderSend error 130
GER30(£),M1: OrderSend(GER30(£),OP_SELLLIMIT,2.0,9889.7,0,0,0,NULL,237502,0,Red)
GER30(£),M1: Alert: 18/03/16 10:57 [GER30(£)]  *** Sell order open failed -error code: 130 (invalid stops)

Firstly, I know I am not supplying any stops, that should be OK. I have tried amending the code to Normalised stops and targets with a 100 pip range just to make sure though; it didn't help :(

I think the problem could be in the value of the entry, but as you can see I have used NormalizeDouble. I am aware of the problem with Print() and that it uses a different precision unless DoubleToString is used, hence the 9889.7000000000001 in the print string above shouldn't be a problem.

Grateful for nay advice or assistance.



Arthur Ockwell
Arthur Ockwell 2016.03.23 13:31  
I am, of course, an idiot and mixed up Limit and Stop...again.
Aleksei Beliakov
Aleksei Beliakov 2016.03.24 06:53  
right you trying to set OP_SELLLIMIT below the market price
Siti Latifah
Siti Latifah 2016.03.28 04:04  

your code=> 


it should be

To add comments, please log in or register