You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Before making any modify order, I check if SL and TP are outside stoplevels: https://book.mql4.com/appendix/limits. This should be enough, yes?
Of course not enough you might as well try to set levels above or below actual Ask or Bid this would result in an immediate orderclose if the modification was accepted.
And you have to check the value of MODE_STOPLEVEL itself because it can be floating.
MODE_STOPLEVEL
14
Stop level in points
A zero value of MODE_STOPLEVEL means either absence of any restrictions on the minimal distance for Stop Loss/Take Profit or the fact that a trade server utilizes some external mechanisms for dynamic level control, which cannot be translated in the client terminal. In the second case, GetLastError() can return error 130, because MODE_STOPLEVEL is actually "floating" here.
Print it... it may reveal something to you.
Whats it gonna be ? takeprofit? or TakeProfitValue?
StopLossValue = LastHighUpFractal + SLMargin; TakeProfitValue = PriceValue - 2 * (StopLossValue - PriceValue);
These values need to be Normalized.
Hi Marco,
Let me try to explain better: When I call my ModifyOrders functions, I have to specify the Order Type. Example:
I use string to specify the Ordertype, because I think its more intuitive, but I could use integers like your suggestion in other forum topic. This isn't the problem...
Once the function ModifyOrders is called, it makes the search of the desire OrderType to change it. The search and order slection it works fine but the ModifyOrder instrution doesn't execute and gives error 130. On previous tests that I made the order was accepted with the same value: Price Value, SL and TP.
Since this error I have been trying to understand what is the error:
- Checking the stoplevels of pending orders:
MarketStopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL)*Point();
- Normalized values:
I have read in the link above that error 130 can have several causes and I trying to find out...
After some code changes the problems remains the same... I send in attachment the mql4 file.
I hope that i have explained better. Feel free to ask...
Move the MarketStopLevel assignment from ModifyOrders() to OnInit().
Move the MarketStopLevel assignment from ModifyOrders() to OnInit().
Or do this...
Of course not enough you might as well try to set levels above or below actual Ask or Bid this would result in an immediate orderclose if the modification was accepted.
And you have to check the value of MODE_STOPLEVEL itself because it can be floating.
MODE_STOPLEVEL
14
Stop level in points
A zero value of MODE_STOPLEVEL means either absence of any restrictions on the minimal distance for Stop Loss/Take Profit or the fact that a trade server utilizes some external mechanisms for dynamic level control, which cannot be translated in the client terminal. In the second case, GetLastError() can return error 130, because MODE_STOPLEVEL is actually "floating" here.
Print it... it may reveal something to you.
Whats it gonna be ? takeprofit? or TakeProfitValue?
These values need to be Normalized.
I have implemented all the requirement limits before any modification order, have checked the MODE_STOPLEVEL and normalized the value that goes on the ModifyOrder, but the problem remains: ERROR 130... I'm going to make a comment to explaint the results...
About TakeProfit or TakeProfitValue, I have corrected to TakeProfit because the name of the variable may confuse. Thanks for the tip.
Or do this...
Ernst, despiste having checked the MODE_STOPLEVEL the problem remains...
The error is the same: 130.
I have tried to increase and decrease a SL margin that I have in code and the result is the same! Trade requirements are fulfilled to proceed to ModifyOrder but still gives error... The log print values when "OP_BUYSTOP" modification orders goes are:
"Dados da modificação de ordens: PV: 1.2098 SL: 1.1795 TP: 1.2704 Ask: 1.19285 Bid: 1.1927 StopLevel: 0.00001 Freeze Level: 0.00000 "
Like I said to Marco, I have tried to increase and decrease the SL margin that I have in code to try not getting error 130 and the result isn't better.
Can I ask someone to test the EA in attachmento in the year of 2006 on EURUSD to see if the result is the same?
Yes it will still give error 130. The idea of my code is to use the previous value if the current one is zero.
Ernst, despiste having checked the MODE_STOPLEVEL the problem remains...
The error is the same: 130.
I have tried to increase and decrease a SL margin that I have in code and the result is the same! Trade requirements are fulfilled to proceed to ModifyOrder but still gives error... The log print values when "OP_BUYSTOP" modification orders goes are:
"Dados da modificação de ordens: PV: 1.2098 SL: 1.1795 TP: 1.2704 Ask: 1.19285 Bid: 1.1927 StopLevel: 0.00001 Freeze Level: 0.00000 "
Like I said to Marco, I have tried to increase and decrease the SL margin that I have in code to try not getting error 130 and the result isn't better.
Can I ask someone to test the EA in attachmento in the year of 2006 on EURUSD to see if the result is the same?
This code was tested without any errors.
This code was tested without any errors.
Ernst, thank you for the help!
If you don't mind I would like to know how do you get there? It was the string conversion that doesn't work? The code has the same value: order index, SL values, type of order...
One more question: I was searching on the mql4 book for operand/expressions to understand the structure of the code that you have written: "MarketStopLevel = (minStop>0.0)?minStop:MarketStopLevel;"
Can you give a link to read?
Ernst, thank you for the help!
If you don't mind I would like to know how do you get there? It was the string conversion that doesn't work? The code has the same value: order index, SL values, type of order...
One more question: I was searching on the mql4 book for operand/expressions to understand the structure of the code that you have written: "MarketStopLevel = (minStop>0.0)?minStop:MarketStopLevel;"
Can you give a link to read?
It wasn't the string conversion because:
Duarte Silva:
This isn't the problem...
Now you successfully hired Ernst for a couple of days to,
Marco vd Heijden:
Rewrite the whole thing the way it should be.https://www.mql5.com/en/docs/basis/operators/ternary