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
Hi Experts
I have created this Label but unable to sort this label.
{ SetLabel("objSymbol", "Symbol", White, 1050, 40); SetLabel("objTrades", "#", White, 990, 40); SetLabel("objLots", "Lots", White, 900, 40); SetLabel("objOpenPnL", "Current", White, 760, 40); SetLabel("objClosedPnL", "Today", White, 650, 40); Assign_Symbols(); totlots =0.0; tottrades = 0.0; totopnl =0.0; totcpnl =0.0; for (int i =0; i <=20; i++) { if(StringLen(symbols[i])==0) break; Output_Row(i, symbols[i]); } int row = i; int clr = Lime; if(totcpnl <0) clr = Red; int clr2 = Lime; if(totopnl <0) clr2 = Red; SetLabel("objSymbol" + row, "GRAND TOTAL", Aqua, 980, 266+ (row + 1)*19,1,20); SetLabel("LINE" + row, "------------------------------- xx --------------------------------------------", White,654, 1300+ (row + 1)*19,1,18); // SetLabel("objTrades" + row, DoubleToStr(tottrades,0), Aqua, 220, 25 + (row + 1)*19); // SetLabel("objLots" + row, DoubleToStr(totlots,2), Aqua, 170, 25 + (row + 1)*19); SetLabel("objOpenPnL" + row, DoubleToStr(totopnl,2), clr2, 800, 260 + (row + 1)*19,1,26); SetLabel("objClosedPnL" + row, DoubleToStr(totcpnl,2), clr, 637, 260 + (row + 1)*19,1,26); //---- //---- return(0); } //+------------------------------------------------------------------+ void Output_Row(int row, string sym) { SetLabel("objSymbol" + row, sym, Yellow,1030, 50 + (row + 1)*30); double trades =0; double lots = 0.0; double opnl = 0.0; double cpnl =0.0; double clots = 0.0; double ctrades = 0; int pos = 1, lcolor = DimGray; for(int i =0; i < OrdersTotal(); i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if((OrderMagicNumber() == MagicNumber || MagicNumber == -1 ) && OrderType ()== OP_BUY && OrderSymbol() == sym || OrderType ()== OP_SELL && OrderSymbol()==sym) { opnl += OrderProfit()+OrderCommission()+OrderSwap(); lots += OrderLots(); trades +=1; if(OrderType() == OP_SELL) pos = -1; } } if (pos == 1) lcolor = Lime; if (pos ==-1) lcolor = Red; int clr = Black; if(opnl <0.0) clr = Red; if(opnl >0.0) clr = Lime; int clr1 = Black; if(trades >0) clr1 = White; if(trades >5) clr1 = Red; int clr2 = Black; if(lots >0) clr2 = Lime; int clr3 = Lime; if(opnl <0) clr3 = Red; SetLabel ("objTrades" + row, DoubleToStr(trades,0), clr1, 990, 50 + (row + 1)*30); SetLabel("objLots" + row, DoubleToStr(lots,2), clr2, 900, 50 + (row + 1)*30); SetLabel("objOpenPnL" + row, DoubleToStr(opnl,2), clr, 775, 50 + (row + 1)*30) ;I want to sort the label ascending or descending either as per number of open trades in an instrument or as per running profit or loss.
will appreciate the help
Regards