這個功用其實只是幫你把該貨幣對所有未平倉的損益加總,不管是 EA 下的單還是手動單。
第一列是損益 (包含利息跟手續費)
第二列是 未平倉淨口數
第三列是損益平衡點
extern string DisplayControl = "Used to Adjust Overlay";
extern bool displayOverlay = true; // Turns the display on and off
extern bool displayLogo = true; // Turns off copyright and icon
extern int displayXcord = 5; // Moves display left and right
extern int displayYcord = 14; // Moves display up and down
extern int displayFontSize = 7; // Changes size of display characters
extern int displaySpacing = 12; // Changes space between lines
extern color displayColor = DeepSkyBlue; // default color of display characters
double pipvalue;
int init()
{
pipvalue=MarketInfo(Symbol(),MODE_TICKVALUE);
LabelCreate();
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
Refresh();
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int y;
int cb=0; // Count buy
int cs=0; // Count sell
double tbl=0; //Count lot size
double tsl=0; //Count lot size
double tl=0; //total lots out
double to=0; //total buy and sell order out
double pr=0;
double pBE=0;
double opB=0;
double opS=0;
//+------------------------------------------------------------------+
//| Calculate Total Profits, Profit Potential and Total Orders |
//+------------------------------------------------------------------+
for (y = 0; y < OrdersTotal(); y++)
{
OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
if ( (OrderSymbol()==Symbol()) && (OrderType()==OP_BUY)) {
cb++;
pr=pr+OrderProfit() + OrderSwap() + OrderCommission();
tbl=tbl+OrderLots();
opB=opB+OrderLots()*OrderOpenPrice();
}
if ( (OrderSymbol()==Symbol()) && (OrderType()==OP_SELL)) {
cs++;
pr=pr+OrderProfit() + OrderSwap() + OrderCommission();
tsl=tsl+OrderLots();
opS=opS+OrderLots()*OrderOpenPrice();
}
tl=tbl-tsl;
to=cb+cs;}
pr = NormalizeDouble(pr,2);
pBE=(opB-opS)/tl;
pBE = NormalizeDouble(pBE,Digits);
ObjectSet("ObjLabel_BE",OBJPROP_PRICE1,pBE);
ObjectSetText("ObjLabel73","Total Lots:",displayFontSize,"Arial Bold",displayColor);
ObjectSet("ObjLabel73",OBJPROP_CORNER,0);
ObjectSet("ObjLabel73",OBJPROP_XDISTANCE,(displayXcord));
ObjectSet("ObjLabel73",OBJPROP_YDISTANCE,(displayYcord+(displaySpacing)));
ObjectSetText("ObjLabel74",DoubleToStr(tl, 2),displayFontSize,"Arial Bold",displayColor);
ObjectSet("ObjLabel74",OBJPROP_CORNER,0);
ObjectSet("ObjLabel74",OBJPROP_XDISTANCE,(displayXcord+75));
ObjectSet("ObjLabel74",OBJPROP_YDISTANCE,(displayYcord+(displaySpacing)));
ObjectSetText("ObjLabel75","BreakEven",displayFontSize,"Arial Bold",displayColor);
ObjectSet("ObjLabel75",OBJPROP_CORNER,0);
ObjectSet("ObjLabel75",OBJPROP_XDISTANCE,(displayXcord));
ObjectSet("ObjLabel75",OBJPROP_YDISTANCE,(displayYcord+(displaySpacing*2)));
ObjectSetText("ObjLabel76",DoubleToStr(pBE, Digits),displayFontSize,"Arial Bold",displayColor);
ObjectSet("ObjLabel76",OBJPROP_CORNER,0);
ObjectSet("ObjLabel76",OBJPROP_XDISTANCE,(displayXcord+75));
ObjectSet("ObjLabel76",OBJPROP_YDISTANCE,(displayYcord+(displaySpacing*2)));
ObjectSetText("ObjLabel21","Portion P/L:",displayFontSize,"Arial Bold",displayColor);
ObjectSet("ObjLabel21",OBJPROP_CORNER,0);
ObjectSet("ObjLabel21",OBJPROP_XDISTANCE,(displayXcord));
ObjectSet("ObjLabel21",OBJPROP_YDISTANCE,(displayYcord));
if(pr >= 0){
ObjectSetText("ObjLabel24",DoubleToStr(pr, 2),displayFontSize,"Arial Bold",Green);
ObjectSet("ObjLabel24",OBJPROP_CORNER,0);
ObjectSet("ObjLabel24",OBJPROP_XDISTANCE,(displayXcord+75));
ObjectSet("ObjLabel24",OBJPROP_YDISTANCE,(displayYcord));}
if(pr < 0){
ObjectSetText("ObjLabel24",DoubleToStr(pr, 2),displayFontSize,"Arial Bold",Red);
ObjectSet("ObjLabel24",OBJPROP_CORNER,0);
ObjectSet("ObjLabel24",OBJPROP_XDISTANCE,(displayXcord+75));
ObjectSet("ObjLabel24",OBJPROP_YDISTANCE,(displayYcord));}
return(0);
}
//+------------------------------------------------------------------+
//| Refresh Object List Function |
//+------------------------------------------------------------------+
void LabelCreate(){
ObjectCreate("ObjLabel_BE",OBJ_HLINE,0,0,0);
ObjectCreate("ObjLabel21",OBJ_LABEL,0,0,0);
ObjectCreate("ObjLabel24",OBJ_LABEL,0,0,0);
ObjectCreate("ObjLabel73",OBJ_LABEL,0,0,0);
ObjectCreate("ObjLabel74",OBJ_LABEL,0,0,0);
ObjectCreate("ObjLabel75",OBJ_LABEL,0,0,0);
ObjectCreate("ObjLabel76",OBJ_LABEL,0,0,0);
return;
}
void Refresh(){
if (displayOverlay) {
ObjectDelete("ObjLabel_BE");
ObjectDelete("ObjLabel21");
ObjectDelete("ObjLabel24");
ObjectDelete("ObjLabel73");
ObjectDelete("ObjLabel74");
ObjectDelete("ObjLabel75");
ObjectDelete("ObjLabel76");
} }