//+------------------------------------------------------------------+ //| 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_PRICE 2 #define SELL_LOTS 3 #define SELL_PRICE 4 #define NET_LOTS 5 #define PROFIT 6 extern color ExtColor=LightSeaGreen; string ExtName="Exposure"; string ExtSymbols[SYMBOLS_MAX]; int ExtSymbolsTotal=0; double ExtSymbolsSummaries[7]; int ExtLines=-1; string ExtCols[8]={"Symbol", "Deals", "Buy lots", "Buy price", "Sell lots", "Sell price", "Net lots", "Profit"}; int ExtShifts[8]={ 10, 80, 130, 180, 260, 310, 390, 460 }; int ExtVertShift=14; double ExtMapBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void init() { IndicatorShortName(ExtName); SetIndexBuffer(0,ExtMapBuffer); SetIndexStyle(0,DRAW_NONE); IndicatorDigits(0); SetIndexEmptyValue(0,0.0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void deinit() { int windex=WindowFind(ExtName); if(windex>0) ObjectsDeleteAll(windex); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ void start() { string name; int i,col,line,windex=WindowFind(ExtName); //---- if(windex<0) return; //---- header line if(ExtLines<0) { for(col=0; col<8; col++) { name="Head_"+col; if(ObjectCreate(name,OBJ_LABEL,windex,0,0)) { ObjectSet(name,OBJPROP_XDISTANCE,ExtShifts[col]); ObjectSet(name,OBJPROP_YDISTANCE,ExtVertShift); ObjectSetText(name,ExtCols[col],9,"Arial",ExtColor); } } ExtLines=0; } //---- ArrayInitialize(ExtSymbolsSummaries,0.0); int total=Analyze(); if(total>0) { line=0; if(ExtSymbolsSummaries[DEALS]>0) { line++; //---- add line if(line>ExtLines) { int y_dist=ExtVertShift*(line+1)+1; for(col=0; col<8; col++) { name="Line_"+line+"_"+col; if(ObjectCreate(name,OBJ_LABEL,windex,0,0)) { ObjectSet(name,OBJPROP_XDISTANCE,ExtShifts[col]); ObjectSet(name,OBJPROP_YDISTANCE,y_dist); } } ExtLines++; } //---- set line int digits=MarketInfo(Symbol(),MODE_DIGITS); double buy_lots=ExtSymbolsSummaries[BUY_LOTS]; double sell_lots=ExtSymbolsSummaries[SELL_LOTS]; double buy_price=0.0; double sell_price=0.0; if(buy_lots!=0) buy_price=ExtSymbolsSummaries[BUY_PRICE]/buy_lots; if(sell_lots!=0) sell_price=ExtSymbolsSummaries[SELL_PRICE]/sell_lots; name="Line_"+line+"_0"; ObjectSetText(name,Symbol(),9,"Arial",ExtColor); name="Line_"+line+"_1"; ObjectSetText(name,DoubleToStr(ExtSymbolsSummaries[DEALS],0),9,"Arial",ExtColor); name="Line_"+line+"_2"; ObjectSetText(name,DoubleToStr(buy_lots,2),9,"Arial",ExtColor); name="Line_"+line+"_3"; ObjectSetText(name,DoubleToStr(buy_price,digits),9,"Arial",ExtColor); name="Line_"+line+"_4"; ObjectSetText(name,DoubleToStr(sell_lots,2),9,"Arial",ExtColor); name="Line_"+line+"_5"; ObjectSetText(name,DoubleToStr(sell_price,digits),9,"Arial",ExtColor); name="Line_"+line+"_6"; ObjectSetText(name,DoubleToStr(buy_lots-sell_lots,2),9,"Arial",ExtColor); name="Line_"+line+"_7"; ObjectSetText(name,DoubleToStr(ExtSymbolsSummaries[PROFIT],2),9,"Arial",ExtColor); } } //---- 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,""); } } //---- to avoid minimum==maximum ExtMapBuffer[Bars-1]=-1; //---- } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int Analyze() { double profit; int i,index,type,total=OrdersTotal(); //---- for(i=0; i0) total++; //---- return(total); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int SymbolsIndex(string SymbolName) { bool found=false; //---- for(int i=0; i=SYMBOLS_MAX) return(-1); //---- i=ExtSymbolsTotal; ExtSymbolsTotal++; ExtSymbols[i]=SymbolName; ExtSymbolsSummaries[DEALS]=0; ExtSymbolsSummaries[BUY_LOTS]=0; ExtSymbolsSummaries[BUY_PRICE]=0; ExtSymbolsSummaries[SELL_LOTS]=0; ExtSymbolsSummaries[SELL_PRICE]=0; ExtSymbolsSummaries[NET_LOTS]=0; ExtSymbolsSummaries[PROFIT]=0; //---- return(i); }//+------------------------------------------------------------------+