//+------------------------------------------------------------------+
//|                                                                  |
//|                                                          SOK.mq4 |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window

// ---- input parameters ----
extern string  pop_roh  = "0=vžavohore, 1=vpravohore, 2=vžavodole, 3=vpravodole";
extern int     roh      = 1;
extern color   Popis    = Yellow;
extern color   Plus     = Aqua;
extern color   Minus    = Orange;
extern color   Hodnota  = White;
extern string  pop_Mini = "true pre m účet, inak false";
extern bool    Mini     = true;
extern int     font     = 14;

double MaxHEG = -10000;
double MinLEG = 10000;
double MaxHEU = -10000;
double MinLEU = 10000;
double MaxHGU = -10000;
double MinLGU = 10000;
double MaxHEJ = -10000;
double MinLEJ = 10000;

double MaxHUJ = -10000;
double MinLUJ = 10000;
double MaxHGJ = -10000;
double MinLGJ = 10000;

// ---- global variable ----
double Usdjpy, Gbpusd,Gbpjpy,Eurusd,Eurgbp,Eurjpy ;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   if (Mini == true)
   {
      Gbpjpy = MarketInfo("GBPJPYm",MODE_BID);
      Usdjpy = MarketInfo("USDJPYm",MODE_BID);
      Gbpusd = MarketInfo("GBPUSDm",MODE_BID);
      Eurjpy = MarketInfo("EURJPYm",MODE_BID);
      Eurusd = MarketInfo("EURUSDm",MODE_BID);
      
      
   }
   
   
   
   else
   {
      Gbpjpy = MarketInfo("GBPJPY",MODE_BID);
      Usdjpy = MarketInfo("USDJPY",MODE_BID);
      Gbpusd = MarketInfo("GBPUSD",MODE_BID);
      Eurjpy = MarketInfo("EURJPY",MODE_BID);
      Eurusd = MarketInfo("EURUSD",MODE_BID);
     
   }

   return(0);
}
  
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
//----
   for(int i = ObjectsTotal() - 1; i>=0; i--)
   {
      string label = ObjectName(i);
      if (StringSubstr (label, 0, 3) != "MPS")
         continue;
      ObjectDelete (label);
   }
//----
   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int    counted_bars=IndicatorCounted();
   
   if (Mini == true)
   {
      Gbpjpy = MarketInfo("GBPJPYm",MODE_BID);
      Usdjpy = MarketInfo("USDJPYm",MODE_BID);
      Gbpusd = MarketInfo("GBPUSDm",MODE_BID);
      Eurjpy = MarketInfo("EURJPYm",MODE_BID);
      Eurusd = MarketInfo("EURUSDm",MODE_BID);
      Eurgbp = MarketInfo("EURGBPm",MODE_BID);
      }
   else
   {
      Gbpjpy = MarketInfo("GBPJPY",MODE_BID);
      Usdjpy = MarketInfo("USDJPY",MODE_BID);
      Gbpusd = MarketInfo("GBPUSD",MODE_BID);
      Eurjpy = MarketInfo("EURJPY",MODE_BID);
      Eurusd = MarketInfo("EURUSD",MODE_BID);
      Eurgbp = MarketInfo("EURGBP",MODE_BID);
   }
   
   double c1=Gbpjpy;
   double c2=Usdjpy;
   double c3=Gbpusd;
   double c4=Eurjpy;
   double c5=Eurusd;
   double c6=Eurgbp;
   
   
   double LevelGJ =((c2*c3)-c1)*100; 
   double LevelEU =((c2*c5)-c4)*100; 
   double LevelGU =((c1/c2)-c3)*10000; 
   double LevelEJ =((c4/c2)-c5)*10000;
   double LevelUJ =((c4/c5)-c2)*100;
   double LevelEG =((c5/c3)-c6)*100;
//GJ   
//////////////////////////////////////////////////////////////     
   if (LevelGJ > MaxHGJ )
   {
      MaxHGJ = LevelGJ;
   }
 
   if (LevelGJ < MinLGJ )
   {
      MinLGJ = LevelGJ;
   }   
  
   Write("MPS_6GJ",  roh, 10, 20, " GBPJPY   New",  font, "Arial Bold", Popis );
   Write("MPS_21GJ", roh, 10, 40, "High", font, "Arial Bold", Popis);
   Write("MPS_26GJ", roh, 10, 60, "Low",  font, "Arial Bold", Popis);
   
   if (LevelGJ > 0)
      Write("MPS_30GJ", roh, 150, 20, DoubleToStr(LevelGJ,Digits)+"   ", font, "Arial Bold", Plus);
       
   if (LevelGJ < 0)
      Write("MPS_30GJ", roh, 150, 20, DoubleToStr(LevelGJ,Digits)+"   ", font, "Arial Bold", Minus);
        
   if (LevelGJ == 0)
      Write("MPS_30GJ", roh, 150, 20, DoubleToStr(LevelGJ,Digits)+"   ", font, "Arial Bold", Popis); 
                
   Write("MPS_99GJ", roh, 150, 40, DoubleToStr(MaxHGJ,Digits) +"   ", font, "Arial Bold", Hodnota);
   Write("MPS_97GJ", roh, 150, 60, DoubleToStr(MinLGJ,Digits) +"   ", font, "Arial Bold", Hodnota);  
////////////////////////////////////////////////////////////

   double offsetY_EU = 210;
// EU   
//////////////////////////////////////////////////////////////     
   if (LevelEU > MaxHEU )
   {
      MaxHEU = LevelEU;
   }
 
   if (LevelEU < MinLEU )
   {
      MinLEU = LevelEU;
   }   
  
   Write("MPS_6EU",  roh, 10, 20+offsetY_EU, " EURUSD  New",font, "Arial Bold", Popis);
   Write("MPS_21EU", roh, 10, 40+offsetY_EU, "High", font, "Arial Bold", Popis);
   Write("MPS_26EU", roh, 10, 60+offsetY_EU, "Low",  font, "Arial Bold", Popis);
   
   if (LevelEU > 0)
      Write("MPS_30EU", roh, 150, 20+offsetY_EU, DoubleToStr(LevelEU,Digits)+"   ", font, "Arial Bold", Plus);
       
   if (LevelEU < 0)
      Write("MPS_30EU", roh, 150, 20+offsetY_EU, DoubleToStr(LevelEU,Digits)+"   ", font, "Arial Bold", Minus);
        
   if (LevelEU == 0)
      Write("MPS_30EU", roh, 150, 20+offsetY_EU, DoubleToStr(LevelEU,Digits)+"   ", font, "Arial Bold", Popis); 
                
   Write("MPS_99EU", roh, 150, 40+offsetY_EU, DoubleToStr(MaxHEU,Digits) +"   ", font, "Arial Bold", Hodnota);
   Write("MPS_97EU", roh, 150, 60+offsetY_EU, DoubleToStr(MinLEU,Digits) +"   ", font, "Arial Bold", Hodnota);  
////////////////////////////////////////////////////////////


   double offsetY_GU = 140; 
// GU   
//////////////////////////////////////////////////////////////     
   if (LevelGU > MaxHGU )
   {
      MaxHGU = LevelGU;
   }
 
   if (LevelGU < MinLGU )
   {
      MinLGU = LevelGU;
   }   
  
   Write("MPS_6GU",  roh, 10, 20+offsetY_GU, " GBPUSD   New",  font, "Arial Bold", Popis );
   Write("MPS_21GU", roh, 10, 40+offsetY_GU, "High", font, "Arial Bold", Popis);
   Write("MPS_26GU", roh, 10, 60+offsetY_GU, "Low",  font, "Arial Bold", Popis);
   
   if (LevelGU > 0)
      Write("MPS_30GU", roh, 150, 20+offsetY_GU, DoubleToStr(LevelGU,Digits)+"   ", font, "Arial Bold", Plus);
       
   if (LevelGU < 0)
      Write("MPS_30GU", roh, 150, 20+offsetY_GU, DoubleToStr(LevelGU,Digits)+"   ", font, "Arial Bold", Minus);
        
   if (LevelGU == 0)
      Write("MPS_30GU", roh, 150, 20+offsetY_GU, DoubleToStr(LevelGU,Digits)+"   ", font, "Arial Bold", Popis); 
                
   Write("MPS_99GU", roh, 150, 40+offsetY_GU, DoubleToStr(MaxHGU,Digits) +"   ", font, "Arial Bold", Hodnota);
   Write("MPS_97GU", roh, 150, 60+offsetY_GU, DoubleToStr(MinLGU,Digits) +"   ", font, "Arial Bold", Hodnota);  
   ////////////////////////////////////////////////////////////


   double offsetY_EJ = 70; 
// EJ 
//////////////////////////////////////////////////////////////     
   if (LevelEJ > MaxHEJ)
   {
      MaxHEJ = LevelEJ;
   }
 
   if (LevelEJ < MinLEJ )
   {
      MinLEJ = LevelEJ;
   }   
  
   Write("MPS_6EJ",  roh, 10, 20+offsetY_EJ, " EURJPY   New",  font, "Arial Bold", Popis );
   Write("MPS_21EJ", roh, 10, 40+offsetY_EJ, "High", font, "Arial Bold", Popis);
   Write("MPS_26EJ", roh, 10, 60+offsetY_EJ, "Low",  font, "Arial Bold", Popis);
   
   if (LevelEJ > 0)
      Write("MPS_30EJ", roh, 150, 20+offsetY_EJ, DoubleToStr(LevelEJ,Digits)+"   ", font, "Arial Bold", Plus);
       
   if (LevelEJ < 0)
      Write("MPS_30EJ", roh, 150, 20+offsetY_EJ, DoubleToStr(LevelEJ,Digits)+"   ", font, "Arial Bold", Minus);
        
   if (LevelEJ == 0)
      Write("MPS_30EJ", roh, 150, 20+offsetY_EJ, DoubleToStr(LevelEJ,Digits)+"   ", font, "Arial Bold", Popis); 
                
   Write("MPS_99EJ", roh, 150, 40+offsetY_EJ, DoubleToStr(MaxHEJ,Digits) +"   ", font, "Arial Bold", Hodnota);
   Write("MPS_97EJ", roh, 150, 60+offsetY_EJ, DoubleToStr(MinLEJ,Digits) +"   ", font, "Arial Bold", Hodnota);  
   ////////////////////////////////////////////////////////////
   
    double offsetY_UJ = 280; 
// EJ 
//////////////////////////////////////////////////////////////     
   if (LevelUJ > MaxHUJ)
   {
      MaxHUJ = LevelUJ;
   }
 
   if (LevelUJ < MinLUJ )
   {
      MinLUJ = LevelUJ;
   }   
  
   Write("MPS_6UJ",  roh, 10, 20+offsetY_UJ, " USDJPY   New",  font, "Arial Bold", Popis );
   Write("MPS_21UJ", roh, 10, 40+offsetY_UJ, "High", font, "Arial Bold", Popis);
   Write("MPS_26UJ", roh, 10, 60+offsetY_UJ, "Low",  font, "Arial Bold", Popis);
   
   if (LevelUJ > 0)
      Write("MPS_30UJ", roh, 150, 20+offsetY_UJ, DoubleToStr(LevelUJ,Digits)+"   ", font, "Arial Bold", Plus);
       
   if (LevelUJ < 0)
      Write("MPS_30UJ", roh, 150, 20+offsetY_UJ, DoubleToStr(LevelUJ,Digits)+"   ", font, "Arial Bold", Minus);
        
   if (LevelUJ == 0)
      Write("MPS_30UJ", roh, 150, 20+offsetY_UJ, DoubleToStr(LevelUJ,Digits)+"   ", font, "Arial Bold", Popis); 
                
   Write("MPS_99UJ", roh, 150, 40+offsetY_UJ, DoubleToStr(MaxHUJ,Digits) +"   ", font, "Arial Bold", Hodnota);
   Write("MPS_97UJ", roh, 150, 60+offsetY_UJ, DoubleToStr(MinLUJ,Digits) +"   ", font, "Arial Bold", Hodnota);  
   ////////////////////////////////////////////////////////////
   
   double offsetY_EG = 350; 
// EJ 
//////////////////////////////////////////////////////////////     
   if (LevelEG > MaxHEG)
   {
      MaxHEG = LevelEG;
   }
 
   if (LevelEG < MinLEG )
   {
      MinLEG = LevelEG;
   }   
  
   Write("MPS_6EG",  roh, 10, 20+offsetY_EG, " EURGBP   New",  font, "Arial Bold", Popis );
   Write("MPS_21EG", roh, 10, 40+offsetY_EG, "High", font, "Arial Bold", Popis);
   Write("MPS_26EG", roh, 10, 60+offsetY_EG, "Low",  font, "Arial Bold", Popis);
   
   if (LevelEG > 0)
      Write("MPS_30EG", roh, 150, 20+offsetY_EG, DoubleToStr(LevelEG,Digits)+"   ", font, "Arial Bold", Plus);
       
   if (LevelEG < 0)
      Write("MPS_30EG", roh, 150, 20+offsetY_EG, DoubleToStr(LevelEG,Digits)+"   ", font, "Arial Bold", Minus);
        
   if (LevelEG == 0)
      Write("MPS_30EG", roh, 150, 20+offsetY_EG, DoubleToStr(LevelEG,Digits)+"   ", font, "Arial Bold", Popis); 
                
   Write("MPS_99EG", roh, 150, 40+offsetY_EG, DoubleToStr(MaxHEG,Digits) +"   ", font, "Arial Bold", Hodnota);
   Write("MPS_97EG", roh, 150, 60+offsetY_EG, DoubleToStr(MinLEG,Digits) +"   ", font, "Arial Bold", Hodnota);  
   ////////////////////////////////////////////////////////////
   return(0);
}
//+------------------------------------------------------------------+
//| Write Procedure                                                  |
//+------------------------------------------------------------------+
void Write(string LBL, double side, int pos_x, int pos_y, string text, int fontsize, string fontname, 
            color Tcolor = CLR_NONE)
{
   ObjectCreate(LBL, OBJ_LABEL, 0, 0, 0);
   ObjectSet(LBL, OBJPROP_CORNER, side);
   ObjectSet(LBL, OBJPROP_XDISTANCE, pos_x);
   ObjectSet(LBL, OBJPROP_YDISTANCE, pos_y);
   ObjectSetText(LBL, text, fontsize, fontname, Tcolor);
}



