MQL4 - automated forex trading   /  

Forum

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

Back to topics list To post a new topic, please log in or register

avatar
190
Jacques366 2008.05.09 19:00 

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





article

Automated Trading Championship 2007

We are glad to inform that preparations for the Automated Trading Championship 2007 have already been started and the contest will certainly take place. There is not very much time left before it starts.


avatar
396
ukt 2008.05.09 20:41 

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



avatar
190
Jacques366 2008.05.10 09:43 
ukt wrote:

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.




avatar
396
ukt 2008.05.11 16:40 

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);




avatar
396
ukt 2008.05.12 15:22 

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 http://forum.mql4.com/11785 - 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


avatar
190
Jacques366 2008.05.13 18:36 
ukt wrote:

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

Back to topics list  

To add comments, please log in or register