Hey guys,
Really strange but when i run the following code it does nothing. GetLastError() returns 130.
But if take the same code and remove the stop & target info it spits out orders just fine.
I am using an empty expert template and just have those two lines of code in the start function.
Not sure whats causing it...
Thanks!
What kind of broker?
fractional point symbol?
What kind of broker?
fractional point symbol?
Im using an IBFX mini account.
Im running it on Eur/Usd
You have your SL and TP calculations wrong
If its a Buy:
SL = Bid - StopLoss* Point
TP = Bid + TakeProfit* Point
If its a Sell:
SL = Ask + StopLoss* Point;
TP = Ask - TakeProfit* Point;
Aside from that, with some brokers you have to do the OrderSend() without SL and TP levels then do OrderModify() and enter the TP and SL
Im using an IBFX mini account.
Im running it on Eur/Usd
Ok.... Sorry for not being specific.
try this:
(1)at ordersend: sl=tp=0. then ordermodify the sl=tp.
(2) eur/usd: what digits? 4 or 5?
You have your SL and TP calculations wrong
If its a Buy:
SL = Bid - StopLoss* Point
TP = Bid + TakeProfit* Point
If its a Sell:
SL = Ask + StopLoss* Point;
TP = Ask - TakeProfit* Point;
Hey bud, I tried swapping the "Ask" I used to define my SL and TP with "Bid" as you suggested but still no luck.
OK it is probably just because you need to do OrderSend() then OrderModify()
Ok.... Sorry for not being specific.
try this:
(1)at ordersend: sl=tp=0. then ordermodify the sl=tp.
(2) eur/usd: what digits? 4 or 5?
1) Yes this method works! Is there any way around this though? I hate the thought of the worst case where the initial order goes in but the modify doesn't occur (connection dies, error occurs, etc etc.)
2) 5 digit broker
for a 5 digit broker you may need to multiply your SL and TP amounts by ten otherwise you TP or stop out at 2.5 pips
Seems to go through fine with the send then modify method. Any ideas how I can get both the order and stop in on the same shot? Id prefer them to go in together in a production environment.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey guys,
Really strange but when i run the following code it does nothing. GetLastError() returns 130.
But if take the same code and remove the stop & target info it spits out orders just fine.
I am using an empty expert template and just have those two lines of code in the start function.
Not sure whats causing it...
Thanks!