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
1.
CONTEXT:
In some cases, it is much better to countdown in the FOR loop: FOR (i=total-1;0<=i;i--){...}
Like this case, (browsing all objects in a chart):
https://forum.mql4.com/9330
QUESTIONS:
In my TrailingStop function below:
- Is it better to countdown in the FOR loop ?
- In general, for orders management, is it better to COUNT DOWN or COUNT UP ?
2.
CONTEXT:
Usually, OpenTrade/CloseTrade custom functions use a WHILE loop trying 3 times to open/close a trade in case of: "TradeDispatcher: trade context is busy".
QUESTION:
In my TrailingStop function below:
- Instead of the MQ4 built in function OrderModify(), should I use a custom function ModifyMyOder() including a WHILE loop trying 3 times to modify the order?
Thanks
int TrailS(string Paire_,int ID_,double TS_) { if(TS_<=0){Error("TrailS:TS<=0");return(0);} double OOP,OSL,OTP,PtTS=Point*TS_; int Ticket; for(int n=OrdersTotal()-1;-1<n;n--){ if(OrderSelect(n,SELECT_BY_POS,MODE_TRADES)){ OTK=OrderTicket (); OOP=OrderOpenPrice (); OSL=OrderStopLoss (); OTP=OrderTakeProfit(); if(0<TS_ && Paire_==OrderSymbol() && ID_==OrderMagicNumber()){ if(OrderType()==OP_BUY){ if(PtTS<Bid-OOP){if(PtTS<Bid-OSL) {OrderModify(OTK,OOP,Bid-PtTS,OTP,0,CLR_NONE);}} } if(OrderType()==OP_SELL){ if(PtTS<OOP-Ask){if(PtTS<OSL-Ask || OSL==0){OrderModify(OTK,OOP,Ask+PtTS,OTP,0,CLR_NONE);}} } } }else{Print("ERROR: TrailS on OrderSelect "+GetLastError());} } return(0); }