I have been using XM brokers and appear to get Invalid Stops occurring more often tyhan elsewhere but in any event don't quite understand what factors can lead to this error
I read the following with WHRoeder's comments - interesting but don't don't think they apply to my circumstances
The following is from my own log file showing a StopLoss of 0 and a TakeProfit 150 points from the OpenPrice (OP) - Option 1 fails Option 2 Fails.
(Just noticed my Magic # appears -ve - must check but doesn't appear to be the problem)
2017.01.11 13:52:40 EURNZD 66625 LTC Trade_Flag = UP OP = 1.50181 MyTP = 1.50331 MySL = 0.00000, My_Trading_Lots = 0.01 SL pts = 0.01273 TP pts = 0.00150
2017.01.11 13:52:40 EURNZD 50010 OBS UP TradeAllowed = 1
2017.01.11 13:52:40 EURNZD 50020 OBS My_OrderSymbol = EURNZD ASK = 1.50252 BID = 1.50181 BUYorSELL = UP My_Trading_Lots = 0.01 My_Slippage = 40 My_TakeProfit = 1.50331 My_StopLoss= 0.00000 My_Comment = FSC.184.108.40.206 My_Magic_Nos = -1473588448
2017.01.11 13:52:40 EURNZD 50021 OBS Ticket = -1
2017.01.11 13:52:40 EURNZD >>>>>>>>>>>.... 50010D BUYorSELL My_error: 130 invalid stops
Simialar log where using the same EA works
2017.01.11 13:45:02 USDCHF 66625 LTC Trade_Flag = DN OP = 1.02058 MyTP = 1.01908 MySL = 0.00000, My_Trading_Lots = 0.01 SL pts = 0.00520 TP pts = 0.00150
2017.01.11 13:45:02 USDCHF 50010 OBS DN TradeAllowed = 1
2017.01.11 13:45:02 USDCHF 50020 OBS My_OrderSymbol = USDCHF ASK = 1.02058 BID = 1.02035 BUYorSELL = DN My_Trading_Lots = 0.01 My_Slippage = 40 My_TakeProfit = 1.01908 My_StopLoss= 0.00000 My_Comment = FSC.27.13.34_.2 My_Magic_Nos = -173588486
2017.01.11 13:45:02 USDCHF 50021 OBS Ticket = 113085977
2017.01.11 13:45:02 USDCHF 50027 OBS Created Ticket = 113085977, OP = 1.02035 Magic = -173588486, MyTP = 1.01908, MySL = 0.00000
2017.01.11 13:45:02 USDCHF 50028 OBS Margin_Used = 7.61
2017.01.11 13:45:02 USDCHF 50021 OBS Ticket = 113085977
any help appreciated
This is the code and haven't seen this error code for a long time (when the S/L & T/P were really wrong) .
I have only seen this with XM
In th examples above the Takeprofit is 150 points and StopLoss 0 for both.
(I put the S/L as zero in attempt to locate the problem).
With zero s/l and T/P 150 points I wouldn't envisage SPREAD being a problem
What a piece of junk !
And incomplete as well you are not showing where these values come from.
Fine - if you don't like it but no need to be insulting.
How about we answer the question - if you wish - rather than throw insults. I do appreciate you guys help of your own accord but I have been coding in my own way for years trying to pick up the best when I can and I am happy that the code normally works fine.
I'm happy with the values and how they are calculated but one example fails with incorrect STOPS and another just a few minutes later does not.
How about we answer the question - if you wish - rather than throw insults.
Marco has posted code to add to yours (for fault finding) not to replace yours. Once you have printed those values, it may become obvious where your problem is.
You might also want to check your broker's stop level:
How are we able to help if you post incomplete code and do not show how these values are calculated ?
That's like going to a garage with only your spare tire and asking them to fix your car.
Exactly, that's not the first time, with exact same code snippet.
And you don't have follow people advice, it's all there already :
Forum on trading, automated trading systems and testing trading strategies
Error 130 : invalid stops
whroeder1, 2016.01.04 12:51
There is Tick, PIP, and Point. They are all different in general. A tick is the smallest change of price. A Point is the least significant digit quoted. In currencies a pip is defined as 0.0001 (or for JPY 0.01)
On a 4 digit broker a point (0.0001) = pip (0.0001). [JPY 0.01 == 0.01] On a 5 digit broker a point (0.00001) = 1/10 pip (0.00010/10). Just because you quote an extra digit doesn't change the value of a pip. (0.0001 == 0.00010) EA's must adjust pips to points (for mq4.) In currencies a tick is a point. Price can change by least significant digit (1.23456 -> 1.23457)
In metals a Tick is still the smallest change but is larger than a point. If price can change from 123.25 to 123.50, you have a TickSize of 0.25 and a point of 0.01. Pip has no meaning.
This is why you don't use TickValue by itself. Only as a ratio with TickSize. See DeltaValuePerLot()
Thanks for the response
I do write them to my own log file with results as above ( I don't believe where they are written to changes the results or problem):-
I just happen to write the details to my own log rather using the PRINT statement
The error refers to invalid stops which I understand to mean the STOPLOSS & TAKEPROFIT figures. The STOPLOSS in all cases is ZERO (used to try track the other problem / snippet Alain refers to). The Takeprofit is 150 points in all cases and I suspect your suggestion WRT the stop level is a possible answer
The following is taken from the JOURNAL at another time
0 00:15:11.250 '8108742': order sell market 0.01 GBPCAD sl: 0.00000 tp: 1.61267
1 00:15:11.377 '8108742': order sell 0.01 GBPCAD opening at market sl: 0.00000 tp: 1.61267 failed [Invalid S/L or T/P]
0 00:15:11.377 '8108742': order sell market 0.01 GBPCHF sl: 0.00000 tp: 1.23777
1 00:15:11.505 '8108742': order sell 0.01 GBPCHF opening at market sl: 0.00000 tp: 1.23777 failed [Invalid S/L or T/P]
0 00:15:11.507 '8108742': order sell market 0.01 GBPUSD sl: 0.00000 tp: 1.21779
0 00:15:11.671 '8108742': order was opened : #112910659 sell 0.01 GBPUSD at 1.21904 sl: 0.00000 tp: 1.21779
The failures occur where the STOPLEVELS are Higher. The attached shows a table I created and using with XM broker and shows some high STOPLEVELS (all figures are points based)
Again Alain's response refers to me to WHRoeders previous post - I already referred to that and believe I understand the content
" That's like going to a garage with only your spare tire and asking them to fix your car." - I disagree it's more like going to the garage and asking them to figure out what's wrong with the tyre that I know is faulty.
If they fix the tyre and the same problem occurs then my fault and probably need to look deeper at what is causing the problem. honest_knave 's suggestion seems most relevant
Apologies but the way the figures are calculated appears irrelevant to me at the moment - unless there is some hidden meaning behind the error message.
Thanks everyone for contributions