if(OrderSelect(openOrderID,SELECT_BY_TICKET)==true)
-
You select by ticket. Verify the ticket is still open.
-
You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and “if long entry” is an incomplete sentence.
Thank you for the reply.
Does this look better?
void OnTimer() { double newSL = iBands(NULL,0,bbPeriod,updatedSL,0,PRICE_CLOSE,0,0); if(OrderSelect(openOrderID,SELECT_BY_TICKET)) { if(OrderType() == OP_BUY && newSL >= ORDER_PRICE_OPEN) { bool Ans = OrderModify(openOrderID,OrderOpenPrice(),newSL,OrderTakeProfit(),0); } else { if(OrderType() == OP_SELL && newSL <= ORDER_PRICE_OPEN)//long position { bool Ans = OrderModify(openOrderID,OrderOpenPrice(),newSL,OrderTakeProfit(),0); } } } }
I think i've done as you said and also changed the new SL so I can set the level as an input.
Hello guys can you please assist me.
I want to install a trading Robot into my MT4-MQL4-Experts folder but after downloding the Robot it does not want to drag and drop into my MQL4-Experts folder, pleasen advise.
IMG_20211216_142744.jpg
IMG_20211216_142759.jpg
Pumi
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone. I've been trying a different strategy recently, however been having issues with the EA not updating as I thought it would. I'm running the update part of the EA on a timer like so:
I've tried multiple variations of the above but can't get it to work. If anyone has any idea why that would be great!