My first Expert: why OrderSend does not work ?

 

Hello,


I am writing my first Expert - Limit/Stop order. The idea is to activate Stop Order only then a certain level (support or resistance) is reached.

It is necessary to input Limit and Stop levels as parameters.

I use command

OrderSend(Symbol(), with parameter OP_BUYSTOP or OP_SELLSTOP

However when this command should be executed, it is not send to terminal.

Maybe other parameters are incorrect ?


Thanks in advance for help,


Edward

 

Hi Edward,

You have to calculate your values like ShortEntryPrice;ShortStopLoss ... to send an order. What are the values of these variables?

 
shad_61:

Hi Edward,

You have to calculate your values like ShortEntryPrice;ShortStopLoss ... to send an order. What are the values of these variables?


ShortEntryPrice, ShortStopLoss, LongEntryPrice are entered manually as inputs

 
Your stop loss and take profit should look like:
OrderSend(Symbol(), OP_SELLSTOP, ShortEntryPrice, lot, 5, Bid+stoploss*Point, Bid-takeprofit*Point, "Sold by Limit_Stop_Order", 0, 0, Red);
and not
OrderSend(Symbol(), OP_SELLSTOP, ShortEntryPrice, lot, 5, stoploss*Point, takeprofit*Point, "Sold by Limit_Stop_Order", 0, 0, Red);
and for buy orders the + and - switch positions and you use ask instead i.e :
OrderSend(Symbol(), OP_BUYSTOP, ShortEntryPrice, lot, 5, Ask-stoploss*Point, Ask+takeprofit*Point, "Sold by Limit_Stop_Order", 0, 0, Red);
 
Thank you, Tonny. Tomorrow I will test my Expert again.