
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
But then OrderModify fails.
The code below is executed after the code above from the last post.
The Log ist:
#ESZ1,M5: Opening Position
#ESZ1,M5: tickvalue: 12.50000000
#ESZ1,M5: pos size: 1.00000000
#ESZ1,M5: Ask/Bid 1242.00000000/1241.75000000
#ESZ1,M5: Spread 0.25000000
#ESZ1,M5: open #13679252 buy 1.00 #ESZ1 at 1242.00 ok
#ESZ1,M5: Order 13679252 Successfully Opened
#ESZ1,M5: SL: 1241.25000000
#ESZ1,M5: TP: 1242.25000000
#ESZ1,M5: error=130
So even first opening and then setting stoploss doesn't seem to work :-/
Spread is 0.25
#ESZ1,M5: Spread 0.25000000
OK, you open a BUY at . . 1242.00 (Ask)
#ESZ1,M5: open #13679252 buy 1.00 #ESZ1 at 1242.00 ok
#ESZ1,M5: Order 13679252 Successfully Opened
Then you try to modify with a TP at the Bid price + 2 * Spread and SL at the Bid price - 2 * Spread
#ESZ1,M5: SL: 1241.25000000
#ESZ1,M5: TP: 1242.25000000
If your FreezeLevel is 0.50 then that is your problem . . what is your FreezeLevel ?
same Problem. The order opens fine with stoploss = 0 and takeprofit = 0.
But then OrderModify fails.
Not adjusting for 4/5 digit brokers. Not opening first and then setting stops.
As previously answered
yes you are probably trading with an ECN broker you have to open orders with zero stops then modify the order after it is opened so there is a problem with 50 pips SL and TP, so do like Raptor said check the freezelevel and stoplevel too just in case
Also check your OrderModify() code .... maybe it works that way, but I feel you should select the order using OrderSelect() before you can do OrderOpenPrice()
Alas #130 is still haunting me at night ;)
Here is my next try:
As you can see, I simplified the example by not using takeprofit. The error definitely occurs due to stoploss, so we don't need takeprofit.
I first open the order with 0 stoploss (and takeprofit) and later try to set stoploss using OrderModify.
Before that I check Mode_Stoplevel and Mode_Freezelevel and adjust stoploss, if needed. (An adjustment occurs below in the log, because stoploss is initially 50, but Mode_Stoplevel is 75, I then set stoploss to Mode_Stoplevel + 1, so 76)
RaptorUK and SDC:
MarketInfo(MODE_FREEZELEVEL) returns 0. I don't think Freezelevel is the problem.
I included the output into the log file.
SDC:
I also inserted an OrderSelect, before calling OrderOpenPrice just to get sure. In the log you can see that OrderSelect worked, otherwise the code would have not proceeded as far (exit -1).
WHRoeder:
I followed SDC's simple example. But I now extended it by using the pips 4/5 Digit adjustment when setting stoploss, as you can see above. You can also see the the order is first opened with stoploss and takeprofit set to zero and then stoploss is set with OrderModify. As you can see in the log below with S/L and T/P set to zero, the order opens up successfully, but I still am unable to set the S/L in the next step with OrderModify.
Here is the complete log:
I am really grateful for your ongoing help and I think we are narrowing down the problem :)
So what else could be the problem? Anything else I could try?
shinobi
Spread is 0.25
#ESZ1,M5: Spread 0.25000000
OK, you open a BUY at . . 1242.00 (Ask)
#ESZ1,M5: open #13679252 buy 1.00 #ESZ1 at 1242.00 ok
#ESZ1,M5: Order 13679252 Successfully Opened
Then you try to modify with a TP at the Bid price + 2 * Spread and SL at the Bid price - 2 * Spread
Isn't your STOP_LEVEL 3 * Spread ? your Stop is too close . . .
Yeah that's why I check the stoplevel here (from the code above):
So in the last example stoploss was set to 76, which is 3*Spread +1.
That should be far away enough, right?
Hey Raptor,
Yeah that's why I check the stoplevel here (from the code above):
So in the last example stoploss was set to 76, which is 3*Spread +1.
That should be far away enough, right?
Here's what I did.
I first wrote a custom function to round doubles to the nearest double:
It does what you expect. If you call it with DoubleRound(1237.687360000), it returns 1237.50.
Then I used it on my S/L just before calling OrderModify. And I used MODE_TICKVALUE, which is 0.25 for #ESZ1.
So:
In the log you can see, that the rounding worked fine. However the stoploss was still rejected :/
I can't imagine what else the problem could be! This #130 is really persistent!!!
You opened a Sell
#ESZ1,M5: open #13708089 sell 1.00 #ESZ1 at 1239.75 ok
and tried to set a SL below it . . .
#ESZ1,M5: SL: 1237.50000000
#ESZ1,M5: error=130