double countprofit(int mode){ double profit=0; if(OrdersTotal()>0){ for(i=OrdersTotal()-1;i>=0;i--){ if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderMagicNumber()==magic){ if(mode==0)profit=profit+(OrderClosePrice()-OrderOpenPrice())/pt; if(mode==1)profit=profit+OrderProfit(); } if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderMagicNumber()==magic){ if(mode==0)profit=profit+(OrderOpenPrice()-OrderClosePrice())/pt; if(mode==1)profit=profit+OrderProfit(); } } } return(profit); } void movetrailingstop(int mode,double trailingstart,double trailingstop){ RefreshRates(); if(OrdersTotal()>0){ for(i=OrdersTotal()-1;i>=0;i--){ OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(mode==0){ if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==magic){ if(OrderType()==OP_BUY){ if(nd(Ask,dg)>nd(OrderOpenPrice()+trailingstart*pt,dg) && nd(OrderStopLoss(),dg)<nd(Bid-(trailingstop+trailingstep)*pt,dg)){ OrderModify(OrderTicket(),OrderOpenPrice(),nd(Bid-trailingstop*pt,dg),OrderTakeProfit(),0,Blue); return; } } else{ if(nd(Bid,dg)<nd(OrderOpenPrice()-trailingstart*pt,dg) && (nd(OrderStopLoss(),dg)>(nd(Ask+(trailingstop+trailingstep)*pt,dg))) || (OrderStopLoss()==0)){ OrderModify(OrderTicket(),OrderOpenPrice(),nd(Ask+trailingstop*pt,dg),OrderTakeProfit(),0,Red); return; } } } }

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
ERROR -> ')' - not all control paths return a value
---------------------------------------------------------------------------------------------------------------------------------
and second error --->>