Is your code within braces, { code }, after the if ?
RaptorUK:
Is your code within braces, { code }, after the if ?
Is your code within braces, { code }, after the if ?
Here is the full code for this section:
if (TrailingStopFunc == true) { for (Count = OrdersTotal()-1; Count >= 0; Count--) if (OrderSelect(Count, SELECT_BY_POS) && OrderType() == OP_SELL && OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol() && OrderTicket() != sOrderNumber) { if (Bid < SellProfitTake) while(IsTradeContextBusy()) Sleep(10); bool Modified = OrderModify(OrderTicket(),OrderOpenPrice(), ModifySellTakeProfit, OrderTakeProfit(),0,Red); sOrderNumber = OrderTicket(); { // Error handling if(Modified == false) { ErrorCode = GetLastError(); ErrDesc = ErrorDescription(ErrorCode); ErrAlert = StringConcatenate("Modify Stoploss - Error ",ErrorCode,": ",ErrDesc); Alert(ErrAlert); ErrLog = StringConcatenate("OrderTicket: ",OrderTicket()); Print(ErrLog); sOrderNumber = 0; } } }
This is what happens . . .
if (Bid < SellProfitTake) // <---- if this is true while(IsTradeContextBusy()) Sleep(10); // <----- this line will be executed . . .
everything after that line gets executed regardless . . .
RaptorUK:
This is what happens . . .
everything after that line gets executed regardless . . .
So how do I resolve this problem? By adding some braces?
ernest02:
So how do I resolve this problem? By adding some braces?
Yes, I would have added some but I don't know what block of code you want to run if (Bid < SellProfitTake)
So how do I resolve this problem? By adding some braces?
RaptorUK:
Yes, I would have added some but I don't know what block of code you want to run if (Bid < SellProfitTake)
Yes, I would have added some but I don't know what block of code you want to run if (Bid < SellProfitTake)
RaptorUK you are definitely going to heaven - and what's more the angels are going to make sure you get some extra rooms with extra thick carpets in your mansion. And I won't be surprised if they throw in a virgin or two! :-)
Thanks a lot man!!
I guess . . .
if (TrailingStopFunc == true) { for (Count = OrdersTotal()-1; Count >= 0; Count--) if (OrderSelect(Count, SELECT_BY_POS) && OrderType() == OP_SELL && OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol() && OrderTicket() != sOrderNumber) { if (Bid < SellProfitTake) { while(IsTradeContextBusy()) Sleep(10); bool Modified = OrderModify(OrderTicket(),OrderOpenPrice(), ModifySellTakeProfit, OrderTakeProfit(),0,Red); sOrderNumber = OrderTicket(); // Error handling if(Modified == false) { ErrorCode = GetLastError(); ErrDesc = ErrorDescription(ErrorCode); ErrAlert = StringConcatenate("Modify Stoploss - Error ",ErrorCode,": ",ErrDesc); Alert(ErrAlert); ErrLog = StringConcatenate("OrderTicket: ",OrderTicket()); Print(ErrLog); sOrderNumber = 0; } } } }
ernest02:
LOL :-) you are most welcome.
Thanks a lot man!!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Here is a simple question for you gurus.
I have a simple "if" statement that lets through everything it seems, in stead of skipping the code after the "if" statement" when the condition is not true. The result is that I get a lot of error 130 - invalid stops unnecessarily. I must be making some simple mistake. Please help me!
Here is the "if" statement:
if (Bid < SellProfitTake)