INVALID_TRADE_PARAMETERS HELP

 

I am trying to place a BuyStop order but I am getting ordersend error 3 (ERR_INVALID_TRADE_PARAMETERS)


I have checked the parameters that I am sending but still can't find the error, could someone help me please?


OrderSend(EURUSD, OP_BUYSTOP, 0.1, 1.563, 5, 1.5615, 1.566,"My order",0, 82800, Green);

Symbol EURUSD

Lots 0.1

Slippage 5 points

Price 1.5630

SL 1.5615

TP 1.5660

Expiration 23 hours = 23*60*60 seconds.


The current ask price is 1.5565


Thank you for your help.

 

L

Some ideas:-

Symbol must be a string

The prices should be all to 4 decimal places (or 5 if that is what the broker is using)

If this is a standard account, the minimum lot may be 1.0

OrderSend("EURUSD", OP_BUYSTOP, 0.1, 1.5630, 5, 1.5615, 1.5660,"My order",0, 82800, Green);

NB - not all brokers accept expirations

Good Luck

-BB-

 

OrderSend() is expecting a datetime value for Expiration.

If the pending order is to expire 23 hours after being placed:

datetime t=TimeCurrent()+23*60*60;

Or if the pending order is to expire at 11PM:

datetime t=TimeCurrent();

t=t-TimeHour(t)*60*60-TimeMinute(t)*60-TimeSeconds(t)+23*60*60;

 

Thank you.


The problem is with the expiration number. I thought it should be the number of seconds after the order has been placed, but as sxTed pointed out, the function is expecting a datetime value.

I start using:

 
datetime t=TimeCurrent();
 
t=t-TimeHour(t)*60*60-TimeMinute(t)*60-TimeSeconds(t)+23*60*60;
Seems to be ok.

Thank you guys.

Reason: