for (int i = 0; i < OrdersTotal(); i++){ if (OrderSelect(i, SELECT_BY_POS)){ // Breakeven if ((OrderType() == OP_BUY & …
Your OrderSelect loop only selects buy orders.
Thank you!!! One of those things where i've been staring at it too long and not really seeing it anymore. Another set of eyes is all it takes sometimes.
Hello,
As the subject states my automatic move to break even function is only working on buy trades. It is not working on sell trades and i can't see what i'm doing wrong. I'm probably just too close to it but any pointers would be helpful. This function is doing 3 similar things at once. Extra Risk management just prevents multiple buy and sell trades from being open at the same time when i'm using grid strategy. Break Even is just what it sounds like. There is also an incremental trail that takes all open trades and stacks their stop losses so if i'm using move to break even and not extra risk management then i could have several trades a few levels apart and when the market turns around they all stop out profitable at the same time.
Code for module is as follows:
Thanks in advance!
In this line
if ((OrderType() == OP_BUY && OrderStopLoss() < OrderOpenPrice()) || (OrderType() == OP_SELL && OrderStopLoss() > OrderOpenPrice()))
If currently sell order has no stop loss (==0) your condition will never be true. So, you should add another option, like this:
if ((OrderType() == OP_BUY && OrderStopLoss() < OrderOpenPrice()) || (OrderType() == OP_SELL && (OrderStopLoss() > OrderOpenPrice() || OrderStopLoss()==0)))
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
As the subject states my automatic move to break even function is only working on buy trades. It is not working on sell trades and i can't see what i'm doing wrong. I'm probably just too close to it but any pointers would be helpful. This function is doing 3 similar things at once. Extra Risk management just prevents multiple buy and sell trades from being open at the same time when i'm using grid strategy. Break Even is just what it sounds like. There is also an incremental trail that takes all open trades and stacks their stop losses so if i'm using move to break even and not extra risk management then i could have several trades a few levels apart and when the market turns around they all stop out profitable at the same time.
Code for module is as follows:
Thanks in advance!