Hi everyone,
I am a newbie to MQL. I'm trying a testing EA. I am getting Error#130. Couldn't find the reason. Pls find the code below and copy of the journal below.
Please help me find the error.
Error 130, ERR_INVALID_STOPS - Please learn to read the documentation - Runtime Error Codes & Requirements and Limitations in Making Trades
Also read, the following related post: https://www.mql5.com/en/forum/159983
Error 130, ERR_INVALID_STOPS - Please learn to read the documentation - Runtime Error Codes & Requirements and Limitations in Making Trades
Also read, the following related post: https://www.mql5.com/en/forum/159983
It seems the Second SellLimit Order meets most of the requirements. Still it says "Invalid Stops". That is confusing. I'll try to make Market Orders then, but I would like to know exact fix to the error.
It is not a question of if it looks OK or not! It is a fact that your code does NOT check for the various conditions, such as the Stop Level for example. So how to you KNOW if it is OK or not?
StopLevelPoints = MarketInfo( _Symbol, MODE_STOPLEVEL );
Also, for example, for the Buy Order, you are calculating your StopLoss and TakeProfit based on the Ask Price, but a Buy Order will close at the Bid price. So you are not considering the effect the spread will have on the minimum stop size (STOPLEVEL). The reverse is valid for the Sell Order.
EDIT: Also, just noticed that you are placing your Sell Limit Order below the Bid Price (I assume, since you only printed the Ask price), when it must be above.
You MUST check these conditions before placing the order - Requirements and Limitations in Making Trades
Avoid using intermediate variables that have no use elsewhere, it can be confusing in larger blocks of code
Trade_Price = Ask;
PRI = Trade_Price;//OrderOpenPrice();
Trade_Price = PRI - Trade_Gap;
take out PRI
Trade_Price = Ask;
Trade_Price = Trade_Price - Trade_Gap; //Or Trade_Price -= Trade_Gap;
It seems the Second SellLimit Order meets most of the requirements. Still it says "Invalid Stops". That is confusing. I'll try to make Market Orders then, but I would like to know exact fix to the error.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone,
I am a newbie to MQL. I'm trying a testing EA. I am getting Error#130. Couldn't find the reason. Pls find the code below and copy of the journal below.
Please help me find the error.