How Do I SendOrder 1 for Buy Stop with Limit 1 Tick above High and Stop Loss 1 Tick Below Low

 

How do I issue the SendOrder command for a Buy Stop with the Limit set 1 tick above the High and the Stop Loss set 1 tick below the Low? I tried the following:

res=OrderSend(Symbol(),OP_BUYSTOP,.5,High[1]+MathPow(10,-Digits()),0,Low[1]-MathPow(10,-Digits()),0,"",MAGICMA,0,Blue);

check=GetLastError();

if(check!=ERR_NO_ERROR) Print("Message not sent. Error: ", ErrorDescription(check)); 

 

I get the error: invalid stops. 

 
res=OrderSend(Symbol(),OP_BUYSTOP,.5,High[1]+MathPow(10,-Digits()),0,Low[1]-MathPow(10,-Digits()),0,"",MAGICMA,0,Blue);
Invalid stops means the price for the command is too near the actual price.
 
And MathPow(10,-Digits) == _Point == Point() and point is not a tick on metals. MarketInfo(pair, MODE_TICKSIZE)
 

You have to find minimum stop level set by your broker for current instrument.

It's minimum number of points your S/L and T/P must be from order price.

Use this:

 

double stopLevel = MarketInfo(Symbol(), MODE_STOPLEVEL);  // Stop level in points
res=OrderSend(Symbol(),OP_BUYSTOP,.5,High[1]+stopLevel*Point(),0,Low[1]-stopLevel*Point(),0,"",MAGICMA,0,Blue); 

 

If you have fast market movement, you still need to check if order is opened, because price can change in time your order is sent to the broker.

See this for other marketinfoconstants information you can get about trading conditions.

 
Thank you all for the feedback!
Reason: