Open an order, return code: 130, Invalid Stops ???? Help!!

 

Hi,


I am trying to open an order for the first time but I still have the return code 130 annoying me !


Here are the parameters :

double OSize = Lots; (0.2)

double OPrice = Ask; (1.5438)
double OSL = Bid-TakeProfit*Point; (1.5458) TP=20
double OTP = Ask+TakeProfit*Point; (1.5415)
string OComment = "My EA";
datetime OExp = 0;
int ONumber = 12345;
color OArrowColor = Green;

ticket=OrderSend(Symbol(),OP_BUY,OSize,OPrice,3,OSL,OTP,OComment,ONumber,OExp,OArrowColor);
Print("BUY order Sent : Price: ",OPrice," Size: ",OSize," StopLoss: ",OSL,
" TakeProfit: ",OTP," DateExp.: ",OExp);


The result of the Print commande is in the attached file.


I would be so delighted if I could have the solution !!!!!!!!

Thanks

 

Hello J,


The result of the Print commande is in the attached file

file please?



btw, is difficult here as your comments suggest that SL is above Ask and TP is below Ask

double OPrice = Ask; (1.5438)

double OSL = Bid-TakeProfit*Point; (1.5458) TP=20


double OPrice = Ask; (1.5438)
double OTP = Ask+TakeProfit*Point; (1.5415)

eg:

item price
stop loss 1.5458
open 1.5438
take profit 1.5415


Unless I've missed the point here then...

Looks more like: order type wants to be OP_SELL

but of actual initialization of doubles looks right for OP_BUY

See what I'm on about?


Regards

 
ukt:

Hello J,


The result of the Print commande is in the attached file

file please?



btw, is difficult here as your comments suggest that SL is above Ask and TP is below Ask

double OPrice = Ask; (1.5438)

double OSL = Bid-TakeProfit*Point; (1.5458) TP=20


double OPrice = Ask; (1.5438)
double OTP = Ask+TakeProfit*Point; (1.5415)

eg:

item price
stop loss 1.5458
open 1.5438
take profit 1.5415


Unless I've missed the point here then...

Looks more like: order type wants to be OP_SELL

but of actual initialization of doubles looks right for OP_BUY

See what I'm on about?


Regards

Oh, SORRY! I have inverted the figures when I wrote the mail, the formulas where ok.

Here is the attached file (I am just seeing it was not attached because it's a .jpg)



There is more than 1000$ on the account (and of free margin) so that should be on the limits side as far as I understand.

 

Is no trading now, for me at least, need to see in trading times - Monday then...

I am trying to open an order for the first time but I still have the return code 130 annoying me !


Here are the parameters :

double OSize = Lots; (0.2)

double OPrice = Ask; (1.5438)
double OSL = Bid-TakeProfit*Point; (1.5458) TP=20
double OTP = Ask+TakeProfit*Point; (1.5415)
string OComment = "My EA";
datetime OExp = 0;
int ONumber = 12345;
color OArrowColor = Green;

ticket=OrderSend(Symbol(),OP_BUY,OSize,OPrice,3,OSL,OTP,OComment,ONumber,OExp,OArrowColor);
Print("BUY order Sent : Price: ",OPrice," Size: ",OSize," StopLoss: ",OSL,
" TakeProfit: ",OTP," DateExp.: ",OExp);


 
double OSize = 0.2;//Lots; (0.2)

double OPrice = Ask; //(1.5438)
int TakeProfit=20;//my addition
double OSL = Bid-TakeProfit*Point;// (1.5458) TP=20
double OTP = Ask+TakeProfit*Point;// (1.5415)
string OComment = "My EA";
datetime OExp = 0;
int ONumber = 12345;
color OArrowColor = Green;
int ticket;//my addition
ticket=OrderSend(Symbol(),OP_BUY,OSize,OPrice,3,OSL,OTP,OComment,ONumber,OExp,OArrowColor); 
Print("BUY order Sent : Price: ",OPrice," Size: ",OSize," StopLoss: ",OSL,
" TakeProfit: ",OTP," DateExp.: ",OExp);

/*
GBPUSD,M15: close #10378720 buy 0.20 GBPUSD at 1.9587 sl: 1.9562 tp: 1.9605 at price 1.9583
GBPUSD,M15 inputs: option=0; magic_number=0; comment_text=""; 
GBPUSD,M15: BUY order Sent : Price: 1.9585 Size: 0.2 StopLoss: 1.9562 TakeProfit: 1.9605 DateExp.: 0
GBPUSD,M15: open #10378720 buy 0.20 GBPUSD at 1.9587 sl: 1.9562 tp: 1.9605 ok

GBPUSD,M15: close #10378587 buy 0.20 GBPUSD at 1.9583 sl: 1.9559 tp: 1.9602 at price 1.9581
GBPUSD,M15 inputs: option=0; magic_number=0; comment_text=""; 
GBPUSD,M15: BUY order Sent : Price: 1.9582 Size: 0.2 StopLoss: 1.9559 TakeProfit: 1.9602 DateExp.: 0
GBPUSD,M15: open #10378587 buy 0.20 GBPUSD at 1.9583 sl: 1.9559 tp: 1.9602 ok
*/

See above for what small changes made to allow test

to allow compile... Your code not altered in any fundamental way excepting declaring int ticket; and using your initiaization values for OSize, TakeProfit

See below for snapshots of confirm/success for both orders

.

Suggest talk to broker or? maybe do Print() of all variables used in call; check all settings in Terminal > Tools > Options > Expert Advisors tab; check EA startup inputs pop up window;

MarketInfo() might be of use - would show info known by trade environment and specified Symbol() (have looksee at https://www.mql5.com/en/forum/107897 - maybe of use...)

Over to you, not see what else I can do here as your code worked on my platform...

good luck

.

" BUY order Sent" are Print() lines

.

.

ORDER 1 #10378587

.

ORDER 2 #10378720

 
ukt:

double OSize = 0.2;//Lots; (0.2)

double OPrice = Ask; //(1.5438)
int TakeProfit=20;//my addition
double OSL = Bid-TakeProfit*Point;// (1.5458) TP=20
double OTP = Ask+TakeProfit*Point;// (1.5415)
string OComment = "My EA";
datetime OExp = 0;
int ONumber = 12345;
color OArrowColor = Green;
int ticket;//my addition
ticket=OrderSend(Symbol(),OP_BUY,OSize,OPrice,3,OSL,OTP,OComment,ONumber,OExp,OArrowColor); 
Print("BUY order Sent : Price: ",OPrice," Size: ",OSize," StopLoss: ",OSL,
" TakeProfit: ",OTP," DateExp.: ",OExp);

/*
GBPUSD,M15: close #10378720 buy 0.20 GBPUSD at 1.9587 sl: 1.9562 tp: 1.9605 at price 1.9583
GBPUSD,M15 inputs: option=0; magic_number=0; comment_text=""; 
GBPUSD,M15: BUY order Sent : Price: 1.9585 Size: 0.2 StopLoss: 1.9562 TakeProfit: 1.9605 DateExp.: 0
GBPUSD,M15: open #10378720 buy 0.20 GBPUSD at 1.9587 sl: 1.9562 tp: 1.9605 ok

GBPUSD,M15: close #10378587 buy 0.20 GBPUSD at 1.9583 sl: 1.9559 tp: 1.9602 at price 1.9581
GBPUSD,M15 inputs: option=0; magic_number=0; comment_text=""; 
GBPUSD,M15: BUY order Sent : Price: 1.9582 Size: 0.2 StopLoss: 1.9559 TakeProfit: 1.9602 DateExp.: 0
GBPUSD,M15: open #10378587 buy 0.20 GBPUSD at 1.9583 sl: 1.9559 tp: 1.9602 ok
*/

See above for what small changes made to allow test

to allow compile... Your code not altered in any fundamental way excepting declaring int ticket; and using your initiaization values for OSize, TakeProfit

See below for snapshots of confirm/success for both orders

.

Suggest talk to broker or? maybe do Print() of all variables used in call; check all settings in Terminal > Tools > Options > Expert Advisors tab; check EA startup inputs pop up window;

MarketInfo() might be of use - would show info known by trade environment and specified Symbol() (have looksee at 'Error Order Send 138.' - maybe of use...)

Over to you, not see what else I can do here as your code worked on my platform...

good luck

.

" BUY order Sent" are Print() lines

.

.

ORDER 1 #10378587

.

ORDER 2 #10378720

Thanks a lot for your help.

I have changed the platform and everything is ok now. I probably will check that thing later one...

Thank again I can carry on my first steps with mql4 :-)

Jacques

Reason: