//+------------------------------------------------------------------+ 
//|   tro_market_info                                                | 
//|                                                                  | 
//|   Copyright © 2008, AVERY T. HORTON, JR. AKA TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|                                                                  |
//|   GIFTS AND DONATIONS ACCEPTED                                   | 
//|   All my indicators should be considered donationware. That is   |
//|   you are free to use them for your personal use, and are        |
//|   under no obligation to pay for them. However, if you do find   |
//|   this or any of my other indicators help you with your trading  |
//|   then any Gift or Donation as a show of appreciation is         |
//|   gratefully accepted.                                           |
//|                                                                  |
//|   Gifts or Donations also keep me motivated in producing more    |
//|   great free indicators. :-)                                     |
//|                                                                  |
//|   PayPal - THERUMPLEDONE@GMAIL.COM                               |  
//+------------------------------------------------------------------+ 
 

#property indicator_chart_window

extern int myChartX   = 450 ;
extern int myChartY   = 0 ;
extern int myCorner   = 0 ;
extern string myFont  = "Courier" ;
extern int myFontSize = 12 ;
 



double Hi, Li, C;

double prev_high, prev_low, prev_close, D, p, value ;
int h  ;
string lbl[15], lbl2[15];
int n, j, i, shift, stop, nHH, nLL  ;

color pColor = Blue ;

string symbol, tChartPeriod, ShortName ;  

int    digits, period, win ; 
double    H1L0, L1H0 ;

double point,  open, high, low, close, mid, range, pClose, pOpen, pHigh, pLow, pMid, pRange, cRange  ;  
double xMax = - 1,  xMin = 9999999999999, xDiff, xClose, xHigh, xLow, xRunUp, xRunDn, xPain ;
double High0, Low0, Open0,  Close0, Open1,High1, Low1, Close1   ;  
 
 
 
      
      
//+------------------------------------------------------------------+

int init()
  {
   period       =  Period() ; 
   tChartPeriod =  TimeFrameToString(period) ;
   symbol       =  Symbol() ;
   digits       =  Digits ;
   point        =  Point ;
   ShortName    =  "MKTINFO"+symbol+period ;
   win          =  0 ;
   
   return(0);
  }
  
//+------------------------------------------------------------------+
int deinit()
  {
 
ObjectsDeleteAll();
 
   return(0);
  }
  
//+------------------------------------------------------------------+
int start()
{

n        = 10;
 
RefreshRates();  
 
int    MODEDIGITS            = MarketInfo(symbol,MODE_DIGITS) ; 
double MODEPOINT             = MarketInfo(symbol,MODE_POINT) ;   
double MODEBID               = MarketInfo(symbol, MODE_BID);  
double MODELOW               = MarketInfo(symbol,MODE_LOW) ;    
double MODEHIGH              = MarketInfo(symbol,MODE_HIGH) ;   
double MODETIME              = MarketInfo(symbol,MODE_TIME) ;   
double MODEASK               = MarketInfo(symbol,MODE_ASK) ;   
double MODESPREAD            = MarketInfo(symbol,MODE_SPREAD) ;  
double MODESTOPLEVEL         = MarketInfo(symbol,MODE_STOPLEVEL) ;   
double MODELOTSIZE           = MarketInfo(symbol,MODE_LOTSIZE) ;   
double MODETICKVALUE         = MarketInfo(symbol,MODE_TICKVALUE) ;   
double MODETICKSIZE          = MarketInfo(symbol,MODE_TICKSIZE) ;    
double MODESWAPLONG          = MarketInfo(symbol,MODE_SWAPLONG) ;   
double MODESWAPSHORT         = MarketInfo(symbol,MODE_SWAPSHORT) ;  
double MODEMINLOT            = MarketInfo(symbol,MODE_MINLOT) ;   
double MODELOTSTEP           = MarketInfo(symbol,MODE_LOTSTEP) ;     
double MODEMAXLOT            = MarketInfo(symbol,MODE_MAXLOT) ;    
double MODESWAPTYPE          = MarketInfo(symbol,MODE_SWAPTYPE) ;    
double MODEPROFITCALCMODE    = MarketInfo(symbol,MODE_PROFITCALCMODE) ;    
double MODEMARGINCALCMODE    = MarketInfo(symbol,MODE_LOTSTEP) ;    
double MODEMARGININIT        = MarketInfo(symbol,MODE_MARGININIT) ;    
double MODEMARGINMAINTENANCE = MarketInfo(symbol,MODE_MARGINMAINTENANCE) ;    
double MODEMARGINHEDGED      = MarketInfo(symbol,MODE_MARGINHEDGED) ;    
double MODEMARGINREQUIRED    = MarketInfo(symbol,MODE_MARGINREQUIRED) ;    
double MODEFREEZELEVEL       = MarketInfo(symbol,MODE_FREEZELEVEL) ;    
   



j       = 0 ;
lbl[j]  = ShortName+j;
lbl2[j] = tChartPeriod + " MarketInfo " + symbol;
DoShow(j, SteelBlue);

j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODETIME  " + TimeToStr(MODETIME);
//DoColor( range, pRange ) ; 
DoShow(j, SteelBlue); 


j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODEBID  " + DoubleToStr(MODEBID,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, Orange); 

j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODEASK  " + DoubleToStr(MODEASK,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, Orange); 



j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODESPREAD  " + DoubleToStr(MODESPREAD,0);
//DoColor( range, pRange ) ; 
DoShow(j, Orange); 



j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODEHIGH " + DoubleToStr(MODEHIGH,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, Green); 

j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODELOW  " + DoubleToStr(MODELOW,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, Red); 


j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODEPOINT  " + DoubleToStr(MODEPOINT,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, Orange); 

j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODEDIGITS  " + DoubleToStr(MODEDIGITS,0);
//DoColor( range, pRange ) ; 
DoShow(j, Orange); 

//---------


j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODETICKVALUE  " + DoubleToStr(MODETICKVALUE,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, SteelBlue); 

j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODETICKSIZE   " + DoubleToStr(MODETICKSIZE,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, SteelBlue); 

//---------


j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODELOTSIZE  " + DoubleToStr(MODELOTSIZE,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, Orange); 

j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODESTOPLEVEL  " + DoubleToStr(MODESTOPLEVEL,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, Orange); 

//---------


j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODESWAPLONG " + DoubleToStr(MODESWAPLONG,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, SteelBlue); 

j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODESWAPSHORT " + DoubleToStr(MODESWAPSHORT,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, SteelBlue); 

j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODESWAPTYPE " + DoubleToStr(MODESWAPTYPE,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, SteelBlue); 
//---------
j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODEMAXLOT  " + DoubleToStr(MODEMAXLOT,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, Orange); 

j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODEMINLOT  " + DoubleToStr(MODEMINLOT,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, Orange); 


j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODELOTSTEP  " + DoubleToStr(MODELOTSTEP,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, Orange); 
//---------


j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODEMARGININIT " + DoubleToStr(MODEMARGININIT,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, SteelBlue); 

j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODEMARGINMAINTENANCE " + DoubleToStr(MODEMARGINMAINTENANCE,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, SteelBlue); 

//---------

j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODEMARGINHEDGED  " + DoubleToStr(MODEMARGINHEDGED,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, Orange); 


j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODEMARGINREQUIRED  " + DoubleToStr(MODEMARGINREQUIRED,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, Orange); 

j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = "MODE_FREEZELEVEL  " + DoubleToStr(MODE_FREEZELEVEL,MODEDIGITS);
//DoColor( range, pRange ) ; 
DoShow(j, Orange); 


//---------












   return(0);
  }

//+------------------------------------------------------------------+
  
void DoShow( int u, color dsColor )
{
ObjectCreate(lbl[u],23,0,Time,PRICE_CLOSE);
ObjectSet(lbl[u], OBJPROP_CORNER, myCorner );
ObjectSet(lbl[u],OBJPROP_XDISTANCE, myChartX);
ObjectSet(lbl[u],OBJPROP_YDISTANCE,n+myChartY);
ObjectSetText(lbl[u],lbl2[u],myFontSize,myFont,dsColor);
n = n+20;

   return(0);
  }

//+------------------------------------------------------------------+
  
void DoColor( double c1, double c2 )
{

if(c1 > c2 ) { pColor = Lime ; } else {
if(c1 < c2 ) { pColor = Red ; } else { pColor = Yellow ; } } 

}  
  
//+------------------------------------------------------------------+
void drawLabel(string name,double lvl,color Color)
{
    if(ObjectFind(name) != 0)
    {
        ObjectCreate(name, OBJ_TEXT, 0, Time[10], lvl);
        ObjectSetText(name, name, myFontSize, myFont , EMPTY);
        ObjectSet(name, OBJPROP_COLOR, Color);
    }
    else
    {
        ObjectMove(name, 0, Time[10], lvl);
    }
}

//+------------------------------------------------------------------+
void drawLine(double lvl,string name, color Col,int type)
{
         if(ObjectFind(name) != 0)
         {
            ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);
            
            if(type == 1)
            ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);
            else
            ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);
            
            ObjectSet(name, OBJPROP_COLOR, Col);
            ObjectSet(name,OBJPROP_WIDTH,1);
            
         }
         else
         {
            ObjectDelete(name);
            ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);
            
            if(type == 1)
            ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);
            else
            ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);
            
            ObjectSet(name, OBJPROP_COLOR, Col);        
            ObjectSet(name,OBJPROP_WIDTH,1);
          
         }
}

//+------------------------------------------------------------------+

string TimeFrameToString(int tf)
{
   string tfs;
   switch(tf) {
      case PERIOD_M1:  tfs="M1"  ; break;
      case PERIOD_M5:  tfs="M5"  ; break;
      case PERIOD_M15: tfs="M15" ; break;
      case PERIOD_M30: tfs="M30" ; break;
      case PERIOD_H1:  tfs="H1"  ; break;
      case PERIOD_H4:  tfs="H4"  ; break;
      case PERIOD_D1:  tfs="D1"  ; break;
      case PERIOD_W1:  tfs="W1"  ; break;
      case PERIOD_MN1: tfs="MN";
   }
   return(tfs);
}

//+------------------------------------------------------------------+
/*

*/