JohnAdams:
New to mql4, I wrote the following code for practice, but can't figure out why I get an Error 130
I think it has to do with unNormalized numbers. I'm using IBFX broker and they use the 5th decimal on the price.
double Stoploss = 50;
double Takeprofit = 50;
int start()
{
int ticket = OrderSend(Symbol(),OP_BUY,1.0,Ask,3,Ask-Stoploss*Point,
Ask+Takeprofit*Point,"Order #1",1234,0,Red);
if(ticket == -1) Print("error-",GetLastError());
return(0);
}
I also tried setting SL and TP to 500 because of the 5th decimal but got the same error. Any suggestions? Thanks
New to mql4, I wrote the following code for practice, but can't figure out why I get an Error 130
I think it has to do with unNormalized numbers. I'm using IBFX broker and they use the 5th decimal on the price.
double Stoploss = 50;
double Takeprofit = 50;
int start()
{
int ticket = OrderSend(Symbol(),OP_BUY,1.0,Ask,3,Ask-Stoploss*Point,
Ask+Takeprofit*Point,"Order #1",1234,0,Red);
if(ticket == -1) Print("error-",GetLastError());
return(0);
}
I also tried setting SL and TP to 500 because of the 5th decimal but got the same error. Any suggestions? Thanks
NormalizeDouble(Value, Digits) helps for normalize the price.
MarketInfo and Stoplevel will help you to determine the min allowed distance between price and SL/TP
Some Brokers need 0 for Stoploss and 0 for Takeprofit in OrderSend. After succesfully send the order you can modify and set the SL and TP
Search for ECN Broker
ok, thanks to both, I'll try out these suggestions..
int ticket = OrderSend(Symbol(),OP_BUY,1.0,Ask,3,Ask-Stoploss*Point,
- For a buy you open at the ask but the stops are relative to the Bid.
- On a ECN broker you must open with no TP/SL and modify afterwords.
- For a 5 digit broker you must modify TP, SL and slippage
//++++ These are adjusted for 5 digit brokers. double pips2points, // slippage 3 pips 3=points 30=points pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
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
I think it has to do with unNormalized numbers. I'm using IBFX broker and they use the 5th decimal on the price.
double Stoploss = 50;
double Takeprofit = 50;
int start()
{
int ticket = OrderSend(Symbol(),OP_BUY,1.0,Ask,3,Ask-Stoploss*Point,
Ask+Takeprofit*Point,"Order #1",1234,0,Red);
if(ticket == -1) Print("error-",GetLastError());
return(0);
}
I also tried setting SL and TP to 500 because of the 5th decimal but got the same error. Any suggestions? Thanks