//+------------------------------------------------------------------+ //| iExposure.mq4 | //| Copyright © 2007, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_buffers 1 //#property indicator_minimum 0.0 //#property indicator_maximum 0.1 #define SYMBOLS_MAX 1024 #define DEALS 0 #define BUY_LOTS 1 #define BUY_ORDERS 2 #define SELL_LOTS 3 #define SELL_ORDERS 4 #define TOTAL_LOTS 5 #define GPROFIT 6 #define GLOSS 7 #define PROFIT 8 extern color HeaderColor=Red; extern color SymbolColor=Lime; extern color TextColor=White; extern int TextSize=10; extern int RowSpacing=14; string Name="History"; string Symbols[SYMBOLS_MAX]; int SymbolsTotal=0; double SymbolsSummaries[SYMBOLS_MAX][9]; int Lines=-1; string Cols[8]={"Symbol", "Deals", "Buy lots", "Buy deals", "Sell lots", "Sell deals", "Total lots", "Profit", "Loss", "Net P/L"}; int Shifts[10]={ 10, 80, 130, 180, 260, 310, 390, 460, 560, 660 }; double MapBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void init() { IndicatorShortName(Name); SetIndexBuffer(0,MapBuffer); SetIndexStyle(0,DRAW_NONE); IndicatorDigits(0); SetIndexEmptyValue(0,0.0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void deinit() { int windex=WindowFind(Name); if(windex>0) ObjectsDeleteAll(windex); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ void start() { string name; int i,col,line,windex=WindowFind(Name); //---- if(windex<0) return; //---- header line if(Lines<0) { for(col=0; col<10; col++) { name="Head_"+col; if(ObjectCreate(name,OBJ_LABEL,windex,0,0)) { ObjectSet(name,OBJPROP_XDISTANCE,Shifts[col]); ObjectSet(name,OBJPROP_YDISTANCE,RowSpacing); ObjectSetText(name,Cols[col],9,"Arial",HeaderColor); } } Lines=0; } //---- ArrayInitialize(SymbolsSummaries,0.0); int total=Analyze(); if(total>0) { line=0; for(i=0; iLines) { int y_dist=RowSpacing*(line+1)+1; for(col=0; col<10; col++) { name="Line_"+line+"_"+col; if(ObjectCreate(name,OBJ_LABEL,windex,0,0)) { ObjectSet(name,OBJPROP_XDISTANCE,Shifts[col]); ObjectSet(name,OBJPROP_YDISTANCE,y_dist); } } Lines++; } //---- set line name="Line_"+line+"_0"; ObjectSetText(name,Symbols[i],9,"Arial",SymbolColor); name="Line_"+line+"_1"; ObjectSetText(name,DoubleToStr(SymbolsSummaries[i][DEALS],0),TextSize,"Arial",TextColor); name="Line_"+line+"_2"; ObjectSetText(name,DoubleToStr(SymbolsSummaries[i][BUY_LOTS],2),TextSize,"Arial",TextColor); name="Line_"+line+"_3"; ObjectSetText(name,DoubleToStr(SymbolsSummaries[i][BUY_ORDERS],0),TextSize,"Arial",TextColor); name="Line_"+line+"_4"; ObjectSetText(name,DoubleToStr(SymbolsSummaries[i][SELL_LOTS],2),TextSize,"Arial",TextColor); name="Line_"+line+"_5"; ObjectSetText(name,DoubleToStr(SymbolsSummaries[i][SELL_ORDERS],0),TextSize,"Arial",TextColor); name="Line_"+line+"_6"; ObjectSetText(name,DoubleToStr(SymbolsSummaries[i][BUY_LOTS]+SymbolsSummaries[i][SELL_LOTS],2),TextSize,"Arial",TextColor); name="Line_"+line+"_7"; ObjectSetText(name,DoubleToStr(SymbolsSummaries[i][GPROFIT],2),TextSize,"Arial",TextColor); name="Line_"+line+"_8"; ObjectSetText(name,DoubleToStr(SymbolsSummaries[i][GLOSS],2),TextSize,"Arial",TextColor); name="Line_"+line+"_9"; ObjectSetText(name,DoubleToStr(SymbolsSummaries[i][PROFIT],2),TextSize,"Arial",TextColor); } } //---- remove lines if(totaltotal; line--) { name="Line_"+line+"_0"; ObjectSetText(name,""); name="Line_"+line+"_1"; ObjectSetText(name,""); name="Line_"+line+"_2"; ObjectSetText(name,""); name="Line_"+line+"_3"; ObjectSetText(name,""); name="Line_"+line+"_4"; ObjectSetText(name,""); name="Line_"+line+"_5"; ObjectSetText(name,""); name="Line_"+line+"_6"; ObjectSetText(name,""); name="Line_"+line+"_7"; ObjectSetText(name,""); name="Line_"+line+"_8"; ObjectSetText(name,""); name="Line_"+line+"_9"; ObjectSetText(name,""); } } //---- to avoid minimum==maximum MapBuffer[Bars-1]=-1; //---- } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int Analyze() { double profit,bprofit,sprofit; int i,index,type,total=OrdersHistoryTotal(); //---- for(i=0; i=SYMBOLS_MAX) continue; //---- //SymbolsSummaries[index][DEALS]++; profit=OrderProfit()+OrderCommission()+OrderSwap(); if(profit>=0)SymbolsSummaries[index][GPROFIT]+=profit; else SymbolsSummaries[index][GLOSS]+=profit; SymbolsSummaries[index][PROFIT]=SymbolsSummaries[index][GPROFIT]+SymbolsSummaries[index][GLOSS]; if(type==OP_BUY) { SymbolsSummaries[index][BUY_LOTS]+=OrderLots(); SymbolsSummaries[index][BUY_ORDERS]++; } if(type==OP_SELL) { SymbolsSummaries[index][SELL_LOTS]+=OrderLots(); SymbolsSummaries[index][SELL_ORDERS]++; } SymbolsSummaries[index][DEALS]=SymbolsSummaries[index][SELL_ORDERS]+SymbolsSummaries[index][BUY_ORDERS]; } //---- total=0; for(i=0; i0) total++; } //---- return(total); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int SymbolsIndex(string SymbolName) { bool found=false; //---- for(int i=0; i=SYMBOLS_MAX) return(-1); //---- i=SymbolsTotal; SymbolsTotal++; Symbols[i]=SymbolName; SymbolsSummaries[i][DEALS]=0; SymbolsSummaries[i][BUY_LOTS]=0; SymbolsSummaries[i][BUY_ORDERS]=0; SymbolsSummaries[i][SELL_LOTS]=0; SymbolsSummaries[i][SELL_ORDERS]=0; SymbolsSummaries[i][TOTAL_LOTS]=0; SymbolsSummaries[i][GPROFIT]=0; SymbolsSummaries[i][GLOSS]=0; SymbolsSummaries[i][PROFIT]=0; //---- return(i); } //+------------------------------------------------------------------+