I have an extern double StopLossPips and I would like to make it conditional with an IF statement. Basically I don't want the stop loss to kick in unless some condition exists in the market. In this case price above/below a 5MA. (_Is5MAStopUp) I have tried to implement it within the code where the StopLossPips is referenced and I have put it before the subopenorder and 1-2 other places but not luck. I cant understand why the IF statement will not take. Any help appreciated.
Make your extern an int it's not quite as simple as this . . .
if (StopLossPips > 0)
. . to test if a double value is really zero or not, more information in this thread, please read it: Can price != price ?
Thanks for replying, that if (StopLossPips > 0 ) actually works. I don't know if you mean the other If statement may function if I make the stop loss pips n int.
Make your extern an int not a double.
And read the thread at the link I gave.
Make your extern an int it's not quite as simple as this . . .
. . to test if a double value is really zero or not, more information in this thread, please read it: Can price != price ?
RaptorUK, in both the modify and the send (open) funtions, the stoploss parameter is required to be a double. You can't send an int. Plus, the comparison is to find out if the stop loss is GREATER THAN zero. There is no problem with that comparison.
Yes, you are correct, until the OP wants to test if the SL is greater than a value other than zero or equal to a value other than 0.
I was talking about the variable StopLossPips which, from the variable name, I would assume to be the position of the stoploss relative to the entry in pips, so this can be an interger, for example 10 pips, or if you want more precision change it to StopLossPoints it can stay as an int and the test . . .
if (StopLossPoints > 0)
. . . works reliably. When using it in an OrderSend() or OrderModify() it is used it to calculate the actual StopLoss . . .
double StopLoss; StopLoss = Ask - (StopLossPoints * Point);

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have an extern double StopLossPips and I would like to make it conditional with an IF statement. Basically I don't want the stop loss to kick in unless some condition exists in the market. In this case price above/below a 5MA. (_Is5MAStopUp) I have tried to implement it within the code where the StopLossPips is referenced and I have put it before the subopenorder and 1-2 other places but not luck. I cant understand why the IF statement will not take. Any help appreciated.