
#property strict
#property indicator_chart_window

input double LotSize = 1.00; // Lot Volume 

input color  Text_Color    = DodgerBlue; // Text Color  
input int    Text_Size     = 12; // Text Size
input string Text_Font     = "Tahoma"; // Text Type
input int    Corner_       = 3; // Corner
input int    Left_Right    = 5; 
input int    Up_Down       = 25;

int Pointx;

string AS;

string periodx, TF;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{  
  
   return(INIT_SUCCEEDED);
  }
  
  void OnDeinit(const int reason)
  {
   ObjectDelete("MRy");
  }    
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   
    
    double MR         = MarketInfo(Symbol(),MODE_MARGINREQUIRED);
    double FreeMargin = AccountFreeMargin();
    double howLots    = NormalizeDouble (FreeMargin/MR,2); 
 //   double MRx = MR*LotSize;
     
  
    ObjectCreate(0,"MRy",OBJ_LABEL,0,0,0); 
    ObjectSetText("MRy", "YOLO/All-In = " + DoubleToStr(howLots,2) + " Lots", Text_Size, Text_Font,  Text_Color);
    ObjectSet("MRy", OBJPROP_CORNER, Corner_);
    ObjectSet("MRy", OBJPROP_XDISTANCE, Left_Right);
    ObjectSet("MRy", OBJPROP_YDISTANCE, Up_Down);   
    ObjectSet("MRy", OBJPROP_SELECTABLE, 0);   
    ObjectSet("MRy", OBJPROP_BACK, 1);   
    
   return(rates_total);
  }
//+------------------------------------------------------------------+
