นี่ตัวอย่างนะครับ เอาไปปรับดูครับ
void OnTick()
{
int Ticket,Cntbuy,Cntsell;
double Bpro,Spro;
Cntbuy=0;Cntsell=0;Bpro=0;Spro=0;
for(int i=0;i<=OrdersTotal();i++)
{
Ticket=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
{
Cntbuy++;
Bpro=Bpro+OrderProfit();
}
if(OrderType()==OP_SELL)
{
Cntsell++;
Spro=Spro+OrderProfit();
}
}
}
ObjectCreate("L9",OBJ_LABEL,0,0,0);
ObjectSetText("L9",IntegerToString(Cntbuy),8,"Tahoma",White);
ObjectSet("L9",OBJPROP_XDISTANCE,15);
ObjectSet("L9",OBJPROP_YDISTANCE,40);
ObjectSetInteger(0,"L9",OBJPROP_SELECTABLE,false);
ObjectSet("L9",OBJPROP_CORNER,1);
ObjectCreate("L10",OBJ_LABEL,0,0,0);
ObjectSet("L10",OBJPROP_XDISTANCE,15);
ObjectSet("L10",OBJPROP_YDISTANCE,55);
ObjectSet("L10",OBJPROP_CORNER,1);
ObjectSetInteger(0,"L10",OBJPROP_SELECTABLE,false);
ObjectSetText("L10",IntegerToString(Cntsell),8,"Tahoma",White);
ObjectCreate("L11",OBJ_LABEL,0,0,0);
ObjectSet("L11",OBJPROP_XDISTANCE,15);
ObjectSet("L11",OBJPROP_YDISTANCE,70);
ObjectSet("L11",OBJPROP_CORNER,1);
ObjectSetInteger(0,"L11",OBJPROP_SELECTABLE,false);
ObjectSetText("L11",DoubleToString(Bpro,2),8,"Tahoma",White);
ObjectCreate("L12",OBJ_LABEL,0,0,0);
ObjectSet("L12",OBJPROP_XDISTANCE,15);
ObjectSet("L12",OBJPROP_YDISTANCE,85);
ObjectSet("L12",OBJPROP_CORNER,1);
ObjectSetInteger(0,"L12",OBJPROP_SELECTABLE,false);
ObjectSetText("L12",DoubleToString(Spro,2),8,"Tahoma",White);
ObjectCreate("L13",OBJ_LABEL,0,0,0);
ObjectSet("L13",OBJPROP_XDISTANCE,15);
ObjectSet("L13",OBJPROP_YDISTANCE,100);
ObjectSet("L13",OBJPROP_CORNER,1);
ObjectSetInteger(0,"L13",OBJPROP_SELECTABLE,false);
ObjectSetText("L13",DoubleToString(Bpro+Spro,2),8,"Tahoma",White);
}