In SendOrder, how to make stop loss in points?

 

Hello,

I have this now:

OrderSend(Symbol(),OP_BUY,0.01,Ask,3,0,0,"My order",16384);

so right now I have no stop loss, however I want the stop loss to be in points, for example half a pip or 5 points.

I know the stop loss must be put in as price, but I do not know how to calculate it?

Thanks!

 
dzimidula011: I have this now: so right now I have no stop loss, however I want the stop loss to be in points, for example half a pip or 5 points. I know the stop loss must be put in as price, but I do not know how to calculate it?

The stop loss parameter is a price, so calculate that price. It is simple arithmetic.

In a simplified pseudo code ...

[stop-loss price] = [Ask/Bid at opening] ± [stop-loss in points] * _Point

Please note that ...

  • a Buy order opens at Ask but closes at Bid
  • a Sell order opens at Bid but closes at Ask
 
Fernando Carreiro #:

The stop loss parameter is a price, so calculate that price. It is simple arithmetic.

In a simplified pseudo code ...

Please note that ...

  • a Buy order opens at Ask but closes at Bid
  • a Sell order opens at Bid but closes at Ask

I know it is simple arithmetic but I do not know how to turn price to points and then back to price, if you meant I should do 

Ask - 5 * _Point

as my stop loss, that does not work.

 
dzimidula011 #: I know it is simple arithmetic but I do not know how to turn price to points and then back to price, if you meant I should do as my stop loss, that of course does not work.
Bid - 5 * _Point

A buy order closes at the Bid price, not the Ask price.

Also, 5 points is very little if you have a Stops Level limitation set by the broker. So you will need to check.

 
Fernando Carreiro #:

A buy order closes at the Bid price, not the Ask price.

Also, 5 points is very little if you have a Stops Level limitation set by the broker. So you will need to check.


Yes, I just now understood what you meant by that, thanks!