error 130 (invalid stops) question.

 

Hi all! I am running an EA in a strategy tester, but for some reason it won't place a trade when a trade signal is clearly reached. I added the code "GetLastError()" function to see what error was keeping the EA from placing trades. Next, I ran the EA in the strategy tester again and watched the "journal" to see what errors came up. I received "error 130 invalid stops."

1. What is this error?

2. How can I fix this?

Thank you.

 
WhooDoo22:

Hi all! I am running an EA in a strategy tester, but for some reason it won't place a trade when a trade signal is clearly reached. I added the code "GetLastError()" function to see what error was keeping the EA from placing trades. Next, I ran the EA in the strategy tester again and watched the "journal" to see what errors came up. I received "error 130 invalid stops."

1. What is this error?

2. How can I fix this?

Thank you.


1. look in the documentation, search the Forum.

2. search the Forum.

 
Also . . . you really do need to read and understand what is written here: https://book.mql4.com/appendix/limits
 
WhooDoo22:

Hi all! I am running an EA in a strategy tester, but for some reason it won't place a trade when a trade signal is clearly reached. I added the code "GetLastError()" function to see what error was keeping the EA from placing trades. Next, I ran the EA in the strategy tester again and watched the "journal" to see what errors came up. I received "error 130 invalid stops."

1. What is this error?

2. How can I fix this?

Thank you.

See here codes of errors. Two main reasons of error 130: 1 - when you place order with stopclose its value is inside of freeze level (If the execution price lies within the range defined by the freeze level, the order cannot be modified, cancelled or closed.), 2 - or placing the order the value for stoploss (take profit) it is not normalized.

Do not place stoploss (take profit) very close to the current price, and normalize it.

 
paladin80:

See here codes of errors. Two main reasons of error 130: 1 - when you place order with stopclose its value is inside of freeze level (If the execution price lies within the range defined by the freeze level, the order cannot be modified, cancelled or closed.), 2 - or placing the order the value for stoploss (take profit) it is not normalized.

Do not place stoploss (take profit) very close to the current price, and normalize it.

It's nothing to do with the FreezeLevel . . . " Hi all! I am running an EA in a strategy tester, but for some reason it won't place a trade when a trade signal is clearly reached. " There is no need to Normalize Entry, TP or SL if they are derived from standard price movement
 

Hey thanks much Simon+Paladin80!

Paladin80, I am not familiar with "feeze level" or "normalized". RaptorUK provided me a link https://book.mql4.com/appendix/limits that might educate me on these two terms. I am 99% sure that the error lies within the takeprofit or stoploss values, but there is always that 1% right? :) Thanks for your posts Simon + Paladin80.

 
WhooDoo22:

Hey thanks much Simon+Paladin80!

Paladin80, I am not familiar with "feeze level" or "normalized". RaptorUK provided me a link https://book.mql4.com/appendix/limits that might educate me on these two terms. I am 99% sure that the error lies within the takeprofit or stoploss values, but there is always that 1% right? :) Thanks for your posts Simon + Paladin80.

It's worth the effort, if you can get your head around what is written here: https://book.mql4.com/appendix/limits you will do yourself a big favour, I had a error 130 bug in my code I hadn't been able to resolve, when I finally got to grips with what is written in that article I was able to solve my issue: https://www.mql5.com/en/forum/134846
 
Hmm, it is not always possible to give solution based on the general description of a problem only. If you post a part of code how you send order it would be easier to find error.
 

Yeah Simon, I am reading https://www.mql5.com/en/forum/134846 and like the post that WHRoeder made - "I had problems when I tried using buystops with tp/sl. I thought it was comparing current price vs stops but couldn't ever verify. Could also be ECN, open first THEN set stops." In the past I have placed manual trades with preset sl & tp values. When trying to place the orders with the preset sl & tp values the mt4 terminal did not accept them. I had a similar idea to that of WHRoeder to send the orders without preset sl & tp values, then after the orders were in the market, then set sl+tp values. I belive that the error 130 that I keep getting is possibly the same problem you had in that topic that I visited. (the link in this post). I will educated myself on this topic for now.

Thank you!

 
WhooDoo22:

Yeah Simon, I am reading https://www.mql5.com/en/forum/134846 and like the post that WHRoeder made - "I had problems when I tried using buystops with tp/sl. I thought it was comparing current price vs stops but couldn't ever verify. Could also be ECN, open first THEN set stops."


Your problem won't be an ECN related one if you are running in the Strategy Tester, it doesn't simulate ECN Brokers . . . but your code should certainly be able to work with ECN and non ECN Brokers.
 
paladin80:
Hmm, it is not always possible to give solution based on the general description of a problem only. If you post a part of code how you send order it would be easier to find error.


Coding in mql4 can be extremely maticulous. Which makes isolating errors difficult due to the additional code that is interdependant with the error code...

Example: one block of error code relies on other blocks of correct code, so in order to fully execute the block of error code the blocks of correct code must not be removed.

(playing "doctor" with the error code becomes harder to isolate errors when the error code relies on other blocks of correct code)

This explains why I chose to explain the problem instead of posting the code. It can be frustrating to attempt to locate errors when there is so much code to sort through.

Its like swimming in sh*t :) please excuse me.

Thanks much!

Reason: