//+------------------------------------------------------------------+
//|                                                     SwapMon      |
//|                                                   Lowphat © 2006 |
//+------------------------------------------------------------------+
#property copyright "Lowphat © 2006"
#property link      "mystikvgv@yahoo.com (mail only)"
#property indicator_separate_window

//---- input parameters
extern string MoneyManagementSetting  = "==MoneyManagementSettings==";
extern double  Risk = 10;
extern int PairsTraded = 0;
//----------------------------------
double lotMM;
double  lots=0.1;

//---- Custom pip value
double PointCost()
   {
   double result;
   double BasePointCost;
   string BaseString;
   string String1;
   string String2;
//+------------------------------------------------------------------+
   BasePointCost=MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo(Symbol(),MODE_POINT);
   BaseString=StringSubstr(Symbol(),3,3);
   String1="USD"+BaseString;
   String2=BaseString+"USD";
//+------------------------------------------------------------------+   
   if(BaseString=="USD")
   result=BasePointCost;
//+------------------------------------------------------------------+   
   else if(MarketInfo(String1,MODE_BID)!=0)
   result=BasePointCost*(1/MarketInfo(String1,MODE_BID));
//+------------------------------------------------------------------+   
   else
   result=BasePointCost*MarketInfo(String2,MODE_ASK);
//+------------------------------------------------------------------+   
   return(result);
   }
   

double    swaplong,swapshort;
int spread,pipvalue,Vol,leverage;
int init(){
IndicatorShortName("Stat Monitor ("+Symbol()+")");

return(0);}
int deinit(){return(0);}

int start()
  {
spread=MarketInfo(Symbol(),13);
pipvalue=MarketInfo(Symbol(),MODE_TICKVALUE);
swaplong=NormalizeDouble(MarketInfo(Symbol(),18),2);
swapshort=NormalizeDouble(MarketInfo(Symbol(),19),2);
Vol=Volume[0];
leverage=AccountLeverage();

        ObjectCreate("Stat Monitor1", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        ObjectSetText("Stat Monitor1","Spread:", 9, "Arial Bold", CadetBlue);
        ObjectSet("Stat Monitor1", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor1", OBJPROP_XDISTANCE, 110);
        ObjectSet("Stat Monitor1", OBJPROP_YDISTANCE, 2);
        
        ObjectCreate("Stat Monitor2", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        ObjectSetText("Stat Monitor2",DoubleToStr(spread ,0),9, "Arial Bold", Lime);
        ObjectSet("Stat Monitor2", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor2", OBJPROP_XDISTANCE, 160);
        ObjectSet("Stat Monitor2", OBJPROP_YDISTANCE, 2);
        
        ObjectCreate("Stat Monitor3", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        ObjectSetText("Stat Monitor3","1 Lot :", 9, "Arial Bold", CadetBlue);
        ObjectSet("Stat Monitor3", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor3", OBJPROP_XDISTANCE, 180);
        ObjectSet("Stat Monitor3", OBJPROP_YDISTANCE, 2);
        
        ObjectCreate("Stat Monitor4", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        ObjectSetText("Stat Monitor4",DoubleToStr(PointCost() ,2)+" USD",9, "Arial Bold", Lime);
        ObjectSet("Stat Monitor4", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor4", OBJPROP_XDISTANCE, 220);
        ObjectSet("Stat Monitor4", OBJPROP_YDISTANCE, 2);    
        
        ObjectCreate("Stat Monitor5", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        ObjectSetText("Stat Monitor5","Buy Swap:", 9, "Arial Bold", CadetBlue);
        ObjectSet("Stat Monitor5", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor5", OBJPROP_XDISTANCE, 290);
        ObjectSet("Stat Monitor5", OBJPROP_YDISTANCE, 2);
        
        ObjectCreate("Stat Monitor6", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        if (swaplong>0)
        {
        ObjectSetText("Stat Monitor6",DoubleToStr( swaplong ,2),9, "Arial Bold", Lime);
        }
        else ObjectSetText("Stat Monitor6",DoubleToStr( swaplong ,2),9, "Arial Bold", Red);
        ObjectSet("Stat Monitor6", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor6", OBJPROP_XDISTANCE, 360);
        ObjectSet("Stat Monitor6", OBJPROP_YDISTANCE, 2);
        
        ObjectCreate("Stat Monitor7", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        ObjectSetText("Stat Monitor7","Sell Swap:", 9, "Arial Bold", CadetBlue);
        ObjectSet("Stat Monitor7", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor7", OBJPROP_XDISTANCE, 400);
        ObjectSet("Stat Monitor7", OBJPROP_YDISTANCE, 2);
        
        ObjectCreate("Stat Monitor8", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        if (swapshort>0)
        {
        ObjectSetText("Stat Monitor8",DoubleToStr( swapshort ,2),9, "Arial Bold", Lime);
        }
        else ObjectSetText("Stat Monitor8",DoubleToStr( swapshort ,2),9, "Arial Bold", Red);
        ObjectSet("Stat Monitor8", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor8", OBJPROP_XDISTANCE, 470);
        ObjectSet("Stat Monitor8", OBJPROP_YDISTANCE, 2);
        
        /*ObjectCreate("Stat Monitor7", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        ObjectSetText("Stat Monitor7","Volume:", 10, "Arial Bold", CadetBlue);
        ObjectSet("Stat Monitor7", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor7", OBJPROP_XDISTANCE, 530);//700
        ObjectSet("Stat Monitor7", OBJPROP_YDISTANCE, 2);
        
        ObjectCreate("Stat Monitor8", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        ObjectSetText("Stat Monitor8",DoubleToStr(Vol ,0),10, "Arial Bold", Lime);
        ObjectSet("Stat Monitor8", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor8", OBJPROP_XDISTANCE, 590);
        ObjectSet("Stat Monitor8", OBJPROP_YDISTANCE, 2);*/
        
        ObjectCreate("Stat Monitor9", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        ObjectSetText("Stat Monitor9","Leverage: ", 9, "Arial Bold", CadetBlue);
        ObjectSet("Stat Monitor9", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor9", OBJPROP_XDISTANCE, 510);
        ObjectSet("Stat Monitor9", OBJPROP_YDISTANCE, 2);
        
        ObjectCreate("Stat Monitor10", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        ObjectSetText("Stat Monitor10","1: ", 9, "Arial Bold", Lime);
        ObjectSet("Stat Monitor10", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor10", OBJPROP_XDISTANCE, 570);
        ObjectSet("Stat Monitor10", OBJPROP_YDISTANCE, 2);
        
        ObjectCreate("Stat Monitor11", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        ObjectSetText("Stat Monitor11",DoubleToStr(leverage ,0),9, "Arial Bold", Lime);
        ObjectSet("Stat Monitor11", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor11", OBJPROP_XDISTANCE, 580);
        ObjectSet("Stat Monitor11", OBJPROP_YDISTANCE, 2);
        
        
        ObjectCreate("Stat Monitor12", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        ObjectSetText("Stat Monitor12","Rec.Lot Size: ", 9, "Arial Bold", CadetBlue);
        ObjectSet("Stat Monitor12", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor12", OBJPROP_XDISTANCE, 610);
        ObjectSet("Stat Monitor12", OBJPROP_YDISTANCE, 2); 
        
        ObjectCreate("Stat Monitor13", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
        if(PairsTraded==0){
            lotMM = MathCeil(AccountFreeMargin() * Risk / 10000) / 10;
        } else {
            lotMM = MathCeil(AccountFreeMargin() * Risk / 10000 /PairsTraded) / 10 ;
         }
        if (lotMM < 0.1) lotMM = lots;
        if (lotMM > 1.0) lotMM = MathCeil(lotMM);     
        if (lotMM > 100) lotMM = 100;
        
        ObjectSetText("Stat Monitor13",DoubleToStr(lotMM ,1)+" Lots",9, "Arial Bold", Lime);
        ObjectSet("Stat Monitor13", OBJPROP_CORNER, 0);
        ObjectSet("Stat Monitor13", OBJPROP_XDISTANCE, 690);
        ObjectSet("Stat Monitor13", OBJPROP_YDISTANCE, 2);

   return(0);
  }

