Download MetaTrader 5

Why StopLoss and TakeProfit oftenly have big integer values?

To add comments, please log in or register
cyberglassed
611
cyberglassed  

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
1950
enbo lu  

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

Kourosh Davallou
41787
Kourosh Davallou  

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
18003
Simon Gniadkowski  
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  
Thank you!
To add comments, please log in or register