Download MetaTrader 5
To add comments, please log in or register
Let your idle PCs do something useful. Join MQL5 Cloud Network!
cyberglassed
611
cyberglassed 2013.08.12 02:41 

Hello folks I have the following sample code taken from internet...

input int StopLoss = 1000;
input int TakeProfit = 1000;
...
double positionOpenPrice = PositionGetDouble(POSITION_PRICE_OPEN);
if (StopLoss > 0)
        request.sl = positionOpenPrice - (StopLoss * _Point);
if (TakeProfit > 0)
        request.tp = positionOpenPrice + (TakeProfit * _Point);
if (request.sl > 0 || request.tp > 0)
        OrderSend(request, result);

I would like to know why the StopLoss value is oftently given like that?

I think should be better, say something like (for a buy order): if the stop loss will be 100 pips, then:

request.sl = positionOpenPrice - 0.0100;

Is there some convention to deal with that nomenclature?

input int StopLoss = 1000;
input int TakeProfit = 1000;

Thanks in advance, Cyberglassed.

enbo lu
Moderator
1904
enbo lu 2013.08.12 06:19  

Because the price your broker provieded maybe 5 or 4 digits. So the point maybe 0.00001 or 0.0001.

Kourosh Davallou
39034
Kourosh Davallou 2013.08.12 06:49  

And  You can use the following commands:

int OnInit()
{
int mydigit=1;
 if (_Digits== 3 || _Digits == 5 )
    mydigit=10;

}

...
int stoploss=StopLoss*mydigit;
int takeprofit=TakeProfit*mydigit;  
Simon Gniadkowski
Moderator
17994
Simon Gniadkowski 2013.08.12 09:28  
cyberglassed:

Hello folks I have the following sample code taken from internet...

I would like to know why the StopLoss value is oftently given like that?

I think should be better, say something like (for a buy order): if the stop loss will be 100 pips, then:

Is there some convention to deal with that nomenclature?

Thanks in advance, Cyberglassed.

It's an input for the user to set . . .  this would be better, try it . . .

input int StopLoss = 1000;   // How many points for the SL ?
input int TakeProfit = 1000; // How many points for the TP ?
cyberglassed
611
cyberglassed 2013.08.12 12:46  
Thank you!
/
To add comments, please log in or register