
//+------------------------------------------------------------------+
//|   TRO_SR_RR                                                      |
//|                                                                  | 
//|   Copyright Љ 2008, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFTS AND DONATIONS ACCEPTED                                   | 
//|                                                                  |
//|   therumpledone@gmail.com                                        |  
//+------------------------------------------------------------------+ 

#property  copyright "Copyright Љ 2008, Avery T. Horton, Jr. aka TRO" 
#property  link      "http://www.therumpledone.com/" 

#property indicator_chart_window

//---- input parameters 

extern int  myChartY    = 1 ;
extern bool   UseMSLineDrawFont = false;
extern color    myColorBG = LightYellow ;
extern bool   Sound.Alert    = false ;

extern bool Show.Labels = true ;
extern bool Show.Lines  = true ;
extern bool Show.Gauge  = true ;
extern bool Show.Fibs   = true ;

extern bool Show.Ask    = true ;
extern bool Show.Open   = true ;
extern bool UseBias     = true ;

extern int  BiasPeriod1  = 1440 ;
extern int  BiasPeriod2  = 60 ;

extern string noteTimeNY = " 14:00 server time = 05:00 am pst" ; 
extern string noteTimeAU = " 23:00 server time = 14:00 am pst" ; 

extern string myOpenHHMM = "14:00"; // 05:00 am pst = 14:00 server time 
extern double Open_Line_Style    = STYLE_DASHDOTDOT ;


extern int       myBars       = 21 ;
extern int       myShift      = 1 ;
extern int       myRR         = 1.5 ;


extern color ColorHeading = SteelBlue;
extern color ColorUpper   = Red ;
extern color ColorShort   = Crimson ;
extern color ColorLong    = Green ;
extern color ColorLower   = Blue ;

extern double Fib_Line_Style    = STYLE_DOT ;
extern double Ask_Line_Style    = STYLE_SOLID ;

extern double    iLevel1=0.24; 
extern double    iLevel2=0.382; 
extern double    iLevel3=0.5; 
extern double    iLevel4=0.618; 
extern double    iLevel5=0.76; 

extern color    iColor1=DarkSeaGreen; 
extern color    iColor2=Khaki; 
extern color    iColor3=Gray; 
extern color    iColor4=Khaki; 
extern color    iColor5=DarkSeaGreen; 

extern color    iColorAsk = Navy ; 

//---- buffers

double    myUpper      = 0 ; 
double    myLower      = 0 ;
double    myWindow     = 0 ;

int i;
  
double R1, R2, R3 ;  

double X05 ;
double X06 ;   
double X07 ;
double X08, XRN ; 
double xRet ;
double xRetPct;    
  
string symbol,tChartPeriod ; 

string tLabel01, tLabel02, tLabel03, tLabel04, tLabel05, tLabel06, tLabel07 ;   
string tRes0 = "rrpRes_0" ;
string tSup0 = "rrpSup_0" ;
string rPiv1 = "rrpFib1_0" ;
string rPiv2 = "rrpFib2_0" ;
string rRNG = "rrpRNG_0" ;

double range  ;
double DynR; 
double DynS;  
datetime StartTime;
int digits ;

double Entry, work, goShort = 0, goLong = 0, reward = 0, risk = 0, ratio = 0, pHigh, pLow, pClose, LgTrigger, ShTrigger, pivot ;
double hipv, pvlo, pvpct, fibpct, ShortPL, LongPL, point, close, MaxRatio = 0, MaxReward = 0,MaxRisk = 0;

double Bias1_Open, Bias1_Close, Bias1_High, Bias1_Low, Bias1_Diff, Bias1_Mid, Bias1_Pivot ;

string Bias1_Msg, tBias1_Peroid,   yymmddms  ;

bool long = false , short = false ;

bool Bias1_Long = false , Bias1_Short = false ;

int cd ;

bool OKtoLong   = false ;
bool OKtoShort  = false ; 

bool xAutoCalc = true;
int nHH, nLL; 
string tPIVOT0 ="rrres" ;
string tPIVOT1 ="rrsup" ; 
string tPIVOT2 ="rrslo" ;

string tFib1 = "Fib1_0" ;
string tFib2 = "Fib2_0" ;
string tFib3 = "Fib3_0" ;
string tFib4 = "Fib4_0" ;
string tFib5 = "Fib5_0" ;
string tAsk  = "Ask_0" ;
 

 
color  ColorShortPL = Yellow, ColorLongPL = Yellow, ColorRatio = Yellow, Bias1_Color = Yellow ;

double xfb1; 
double xfb2; 
double xfb3; 
double xfb4; 
double xfb5; 

      string fib1 = "fib1" ;
      string fib2 = "fib2" ;      
      string fib3 = "fib3" ;
      string fib4 = "fib4" ;      
      string fib5 = "fib5" ;
      
datetime Trigger, r ;      

string rec1, rec2, rec3, FontToUse = "Terminal";


double Bias2_Open, Bias2_Close, Bias2_High, Bias2_Low, Bias2_Diff, Bias2_Mid, Bias2_Pivot ;

string Bias2_Msg, tBias2_Peroid , Trade_Msg ;

bool Bias2_Long = false , Bias2_Short = false ;

color Bias2_Color = Yellow, Trade_Color = Yellow ;

//+------------------------------------------------------------------+
   
int init()
{
  if (UseMSLineDrawFont) { FontToUse = "MS LineDraw"; }
   
  symbol       =  Symbol() ;
  tChartPeriod =  TimeFrameToString(Period()) ;

  tLabel01 = "r1Resistance" + tChartPeriod ;
  tLabel02 = "r2Support" + tChartPeriod ;
  tLabel03 = "r3Short" + tChartPeriod ; 
  tLabel04 = "r4Long" + tChartPeriod ;
  
  digits = Digits ;
  point  = Point ;
  
  tBias1_Peroid = TimeFrameToString(BiasPeriod1) ;
  tBias2_Peroid = TimeFrameToString(BiasPeriod2) ;
    
if( Show.Gauge ) DoShowGauge() ;

if( Show.Fibs  ) 
{
      ObjectDelete(fib5);
      ObjectCreate(fib5,OBJ_HLINE,0,0,0);
      ObjectSet(fib5,OBJPROP_COLOR,iColor5);
      ObjectSet(fib5,OBJPROP_STYLE,Fib_Line_Style);
 

      ObjectDelete(fib4);
      ObjectCreate(fib4,OBJ_HLINE,0,0,0);
      ObjectSet(fib4,OBJPROP_COLOR,iColor4);
      ObjectSet(fib4,OBJPROP_STYLE,Fib_Line_Style);
 

      ObjectDelete(fib3);
      ObjectCreate(fib3,OBJ_HLINE,0,0,0);
      ObjectSet(fib3,OBJPROP_COLOR,iColor3);
      ObjectSet(fib3,OBJPROP_STYLE,Fib_Line_Style);
      

      ObjectDelete(fib2);
      ObjectCreate(fib2,OBJ_HLINE,0,0,0);
      ObjectSet(fib2,OBJPROP_COLOR,iColor2);
      ObjectSet(fib2,OBJPROP_STYLE,Fib_Line_Style);
 


      ObjectDelete(fib1);
      ObjectCreate(fib1,OBJ_HLINE,0,0,0);
      ObjectSet(fib1,OBJPROP_COLOR,iColor1);
      ObjectSet(fib1,OBJPROP_STYLE,Fib_Line_Style);
 
}            

if(Show.Ask)
{
      ObjectDelete(tAsk);
      ObjectCreate(tAsk,OBJ_HLINE,0,0,0);
      ObjectSet(tAsk,OBJPROP_COLOR,iColorAsk);
      ObjectSet(tAsk,OBJPROP_STYLE,0);

}

   rec1 = "rec1" ;   
   rec2 = "rec2" ;  
   rec3 = "rec3" ; 

   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectsDeleteAll( 0, OBJ_FIBO ) ;
   ObjectDelete(tPIVOT0);
   ObjectDelete(tPIVOT1); 
   ObjectDelete(tPIVOT2);      
   ObjectDelete("RRRP");
   ObjectDelete("line5RRRP");
   ObjectDelete("R3_lRRRP");
   ObjectDelete("R3_vRRRP");  
   ObjectDelete("R2_lRRRP"); 
   ObjectDelete("R2_vRRRP");
   ObjectDelete("R1_lRRRP");
   ObjectDelete("R1_vRRRP");
   ObjectDelete("Pivot_lRRRP");
   ObjectDelete("Pivot_vRRRP");
   ObjectDelete( "X08_ValueRRR" );
   ObjectDelete(  "X08_LabelRRR" );   
   ObjectDelete( "X09_ValueRRR" );
   ObjectDelete(  "X09_LabelRRR" );   
   ObjectDelete(  "X07_ValueRRR" );
   ObjectDelete(  "X07_LabelRRR" );
   ObjectDelete(  "X06_ValueRRR" );
   ObjectDelete(  "X06_LabelRRR" );
   ObjectDelete(  "X05_ValueRRR" );
   ObjectDelete( "X05_LabelRRR" );
   ObjectDelete(  "X10_ValueRRR" );
   ObjectDelete( "X10_LabelRRR" );   
   ObjectDelete(  "X11_ValueRRR" );
   ObjectDelete( "X11_LabelRRR" );
   ObjectDelete( "X12_LabelRRR" );   
   ObjectDelete(  "X13_ValueRRR" );
   ObjectDelete( "X13_LabelRRR" );   
 
   ObjectDelete( "X14_LabelRRR" );   
   
      
   ObjectDelete("Res_SRP");      
   ObjectDelete("Sup_SRP");           
   ObjectDelete("+618_SRP"); 
   ObjectDelete("+382_SRP");      
   ObjectDelete("-618_SRP"); 
   ObjectDelete("-382_SRP");  
   ObjectDelete( "XRN_ValueRRR" );
   ObjectDelete(  "XRN_LabelRRR" );  
      ObjectDelete(fib5);
      ObjectDelete(fib4); 
      ObjectDelete(fib3); 
      ObjectDelete(fib2); 
      ObjectDelete(fib1);   
      ObjectDelete(tAsk); 
      ObjectDelete(rRNG);


  ObjectDelete("DayTimeOpen"); 
  ObjectDelete("DayOpen"); 

      ObjectDelete(rec1);
      ObjectDelete(rec2);
      ObjectDelete(rec3);
            
                   
   return(0);
  }

int start()
{

DoWork() ;  

DoAlert() ; 

if( Show.Lines) DoShowLabels() ;

if( Show.Gauge ) DoShowGauge() ;

if( Show.Fibs  ) DoShowFibs() ;
 
if( Show.Ask  ) DoShowAsk() ;

if( Show.Open  ) DoShowOpen() ;

 
   WindowRedraw(); 

   return(0); 
} 
//+------------------------------------------------------------------+ 

void DoAlert()
{

   LongPL   = 0 ;
   ShortPL  = 0 ;   
   
   ColorShortPL = Yellow ; 
   ColorLongPL  = Yellow ;
        
   if( OKtoLong && Ask == goLong  && goLong  > Low[0] ) 
   { 
      long  = true; 
      short = false ; 
            
      if( Trigger != Time[0] &&  Sound.Alert )
      { 
         Trigger = Time[0] ;  
         Alert(symbol,"  ", tChartPeriod, " go Long "+ DoubleToStr(close ,digits)); 
      }
   }
        
 
  if( OKtoShort && Bid == goShort && goShort < High[0] )
  {  
      long = false; 
      short = true ;      
      
      if( Trigger != Time[0] &&  Sound.Alert )
      {         
         Trigger = Time[0] ; 
         Alert(symbol,"  ", tChartPeriod, " go Short "+ DoubleToStr(close ,digits)); 
      }
  }     
   
   
  if( OKtoLong )
  {    
   LongPL  = ( Bid - goLong ) / point ;   
   LongPL  = NormalizeDouble( LongPL, 0 ) ;
  }
   
   
  if( OKtoShort )
  {   
   ShortPL = ( goShort - Ask ) / point ; 
   ShortPL = NormalizeDouble( ShortPL, 0 ) ;
  }
  
} 
//+------------------------------------------------------------------+ 

void DoWork()
{
  
/*   
Reward = Target Point - Entry Point = 1.9869-1.9782 = 87 pips

Risk= Entry Point - Stop Loss = 1.9782 - 1.9747 = 35pips

Risk to Reward Ratio = 87 / 35 = 1:2.5

*/


 
 close    =  iClose(NULL,0,0) ; 
 
 nHH      =  Highest(NULL,0,MODE_HIGH,myBars,myShift); 
 nLL      =  Lowest(NULL,0,MODE_LOW,myBars,myShift); 
 
 myUpper      = High[nHH]; 
 myLower      = Low[nLL]; 
  
 

 if( nHH < nLL ) { pClose = Close[nHH]; pHigh  = High[nHH]; pLow = Low[nHH];} 
 else            { pClose = Close[nLL]; pHigh  = High[nLL]; pLow = Low[nLL];}  
 
 
      
   pivot  = ( pHigh + pLow + pClose ) / 3 ;
   pivot  =  NormalizeDouble(pivot,Digits) ;
   hipv   = myUpper - pivot ;
   pvlo   = pivot - myLower ;
 
   work   = MathMin(hipv, pvlo)  ;
 
   goLong  = myLower + work ;
   goLong  = NormalizeDouble(goLong, Digits) ;
   
   goShort = myUpper - work ;    
   goShort = NormalizeDouble(goShort, Digits) ; 
        
   reward   = myUpper - goLong ;
   risk     = goLong - myLower ;
   
   if(risk != 0) { ratio = reward / risk ; } else { ratio = -999 ; } 
   
   range    = myUpper -  myLower ;
   
   if(range != 0) { pvpct = work / ( range ) ; } else { pvpct = -999 ; } 
 


   if(ratio  > myRR   )   { ColorRatio = Green ; } else  { ColorRatio = Red ; }
   
   if(ratio  > MaxRatio)  { MaxRatio  = ratio ; }
   
   if(reward > MaxReward) { MaxReward = reward ; }
   
   if(risk   > MaxRisk)   { MaxRisk   = risk ; }
 
       
            xfb5  = myUpper - range*iLevel1; 
            xfb4  = myUpper - range*iLevel2; 
            xfb3  = myUpper - range*iLevel3; 
            xfb2  = myUpper - range*iLevel4; 
            xfb1  = myUpper - range*iLevel5; 
 
   if(range != 0) { fibpct = 100 * (close - myLower) / range ; } else { fibpct = -999 ; }

//------------   

int   yy = TimeYear(Time[0]);
int   mm = TimeMonth(Time[0]);
int   dd = TimeDay(Time[0]);  
   
  yymmddms = yy+"."+mm+"."+dd+" " + myOpenHHMM ;
         
datetime var1 = StrToTime(yymmddms);  
  
  
datetime day=24*60*60;
         r  = var1 ;


      cd = iBarShift(NULL,0,r,FALSE);

datetime r2=r-day;


if(TimeDayOfWeek(r2)==0) r2=r2-day-day;
int cd2=iBarShift(NULL,0,r2,FALSE);

if( var1 > Time[0] ) { r = r2 ;cd = cd2 ;} // if date/time is greater than current date/time go back 1 day

//------------

OKtoLong   = false ;
OKtoShort  = false ; 

Bias1_Long  = false ; 
Bias1_Short = false ;

 Bias1_Close   = iClose(NULL,BiasPeriod1,0) ; 

 Bias1_High    = iHigh(NULL,BiasPeriod1,1) ; 
 Bias1_Low     = iLow(NULL,BiasPeriod1,1) ;


if( BiasPeriod1 == 1440 ) {Bias1_Open = Open[cd] ; } else {Bias1_Open = iOpen(NULL,BiasPeriod1,0) ; } 
 
  
 Bias1_Diff    = Bias1_Close - Bias1_Open ;
 
 Bias1_Mid     = ( Bias1_High + Bias1_Low ) * 0.50 ;
 Bias1_Mid     = NormalizeDouble( Bias1_Mid , digits ) ;
 
 Bias1_Pivot   = ( Bias1_High + Bias1_Low + Bias1_Close ) * 0.33333 ; 
 Bias1_Pivot   = NormalizeDouble( Bias1_Pivot , digits ) ; 
 
 
  
   if( Bias1_Diff > 0 && Bias1_Close > Bias1_Mid ) { Bias1_Long  = true ; Bias1_Msg = "UP STRONG" ; Bias1_Color = Green   ; } else 
   if( Bias1_Diff > 0 && Bias1_Close < Bias1_Mid ) { Bias1_Long  = true ; Bias1_Msg = "Up Weak" ;   Bias1_Color = Green   ; } else    
   if( Bias1_Diff < 0 && Bias1_Close < Bias1_Mid  ){ Bias1_Short = true ; Bias1_Msg = "DN STRONG" ; Bias1_Color = Red     ; } else 
   if( Bias1_Diff < 0 && Bias1_Close > Bias1_Mid  ){ Bias1_Short = true ; Bias1_Msg = "Dn Weak" ;   Bias1_Color = Red ; } else    
                                                { Bias1_Msg = "No Bias" ;   Bias1_Color = Gray; }



Bias2_Long  = false ; 
Bias2_Short = false ;

 Bias2_Close   = iClose(NULL,BiasPeriod2,0) ; 

 Bias2_High    = iHigh(NULL,BiasPeriod2,1) ; 
 Bias2_Low     = iLow(NULL,BiasPeriod2,1) ;


if( BiasPeriod2 == 1440 ) {Bias2_Open = Open[cd] ; } else {Bias2_Open = iOpen(NULL,BiasPeriod2,0) ; } 
 
  
 Bias2_Diff    = Bias2_Close - Bias2_Open ;
 
 Bias2_Mid     = ( Bias2_High + Bias2_Low ) * 0.50 ;
 Bias2_Mid     = NormalizeDouble( Bias2_Mid , digits ) ;
 
 Bias2_Pivot   = ( Bias2_High + Bias2_Low + Bias2_Close ) * 0.33333 ; 
 Bias2_Pivot   = NormalizeDouble( Bias2_Pivot , digits ) ; 
 
 
  
   if( Bias2_Diff > 0 && Bias2_Close > Bias2_Mid ) { Bias2_Long  = true ; Bias2_Msg = "UP STRONG" ; Bias2_Color = Green   ; } else 
   if( Bias2_Diff > 0 && Bias2_Close < Bias2_Mid ) { Bias2_Long  = true ; Bias2_Msg = "Up Weak" ;   Bias2_Color = Green   ; } else    
   if( Bias2_Diff < 0 && Bias2_Close < Bias2_Mid  ){ Bias2_Short = true ; Bias2_Msg = "DN STRONG" ; Bias2_Color = Red     ; } else 
   if( Bias2_Diff < 0 && Bias2_Close > Bias2_Mid  ){ Bias2_Short = true ; Bias2_Msg = "Dn Weak" ;   Bias2_Color = Red ; } else    
                                                   {                      Bias2_Msg = "No Bias" ;   Bias2_Color = Gray; }
                                                
   if( (UseBias && Bias2_Long )  || !UseBias ) { OKtoLong  = true ; }                                                                                 
   if( (UseBias && Bias2_Short ) || !UseBias ) { OKtoShort = true ; }  


   if( Bias2_Long && Bias1_Long )  { Trade_Msg = "TRADE LONG" ;  Trade_Color = Green ; } else    
   if( Bias2_Long && Bias1_Short ) { Trade_Msg = "Scalp Long" ;  Trade_Color = Green ; } else  
   if( Bias2_Short && Bias1_Long ) { Trade_Msg = "Scalp Short" ; Trade_Color = Red   ; } else 
   if( Bias2_Short && Bias1_Short ){ Trade_Msg = "TRADE SHORT" ; Trade_Color = Red   ; } else
                                   { Trade_Msg = ">>>NO TRADE<<<" ;    Trade_Color = Blue  ; }                                                     
} 

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

 
void DoShowGauge()
{

string StrX05 = "+Fib618" ; 
string StrX06 = "+Fib382" ; 
string StrX07 = "-Fib382" ; 
string StrX08 = "-Fib618" ;  
string StrXRN = "Range" ;  
  
        
	
	int Precision, dig;	

   dig = Digits ;

 
int sPeriod= Period();
     	
//---- Set Pivots labels

   int WindowToUse;
   int Corner_line, Xdist_line;
   int Corner_text, Corner_vRRRP, Xdist_text, Xdist_vRRRP;
   int Ydist_line5;
   int Corner_pivots, Xdist_pivots, Ydist_pivots;
   int Ydist_R3, Ydist_R2, Ydist_R1, Ydist_PV, Ydist_S1, Ydist_S2, Ydist_S3; 
   int Ydist_X05, Ydist_X06, Ydist_X07, Ydist_X08, Ydist_X09, Ydist_X10, Ydist_X11, Ydist_X12, Ydist_X13, Ydist_X14 ;
  
   int YdistInc ;
    WindowToUse =  0;
    Corner_line = 1;
    Corner_text = 1; Corner_vRRRP = 1;
    Xdist_line = 21; Xdist_text = 93; Xdist_vRRRP = 23;
    Corner_pivots = 1; Xdist_pivots = 21; 
    Ydist_pivots = myChartY;  
    Ydist_line5 = Ydist_pivots + 11; YdistInc = 15 ;
    Ydist_R3 = Ydist_pivots + 25; 
    Ydist_R2 = Ydist_R3 + YdistInc; 
    Ydist_R1 = Ydist_R3 + YdistInc*2; 
    Ydist_PV = Ydist_R3 + YdistInc*3; 
    Ydist_X05 = Ydist_R3 + YdistInc*4;
    Ydist_X06 = Ydist_R3 + YdistInc*5;    
    Ydist_X07 = Ydist_R3 + YdistInc*6;
    Ydist_X08 = Ydist_R3 + YdistInc*7;    
    Ydist_X09 = Ydist_R3 + YdistInc*8;      
    Ydist_X10 = Ydist_R3 + YdistInc*9;  
    Ydist_X11 = Ydist_R3 + YdistInc*10;  
    Ydist_X12 = Ydist_R3 + YdistInc*11;   
    Ydist_X13 = Ydist_R3 + YdistInc*12;   
    Ydist_X14 = Ydist_R3 + YdistInc*13;  
    
    
    
  if (ObjectFind(tPIVOT0) != 0)
      {
          ObjectCreate(tPIVOT0,OBJ_ARROW,0,Time[nHH],myLower);
          ObjectSet(tPIVOT0,OBJPROP_ARROWCODE,217);
//          ObjectSet(tPIVOT0,OBJPROP_WIDTH,myBoxWidth);  
          ObjectSet(tPIVOT0,OBJPROP_COLOR,ColorUpper);  
      } 
      else
      {
         ObjectMove(tPIVOT0,0,Time[nHH],myLower);
      }


 
  if (ObjectFind(tPIVOT1) != 0)
      {
          ObjectCreate(tPIVOT1,OBJ_ARROW,0,Time[myBars],myLower);
          ObjectSet(tPIVOT1,OBJPROP_ARROWCODE,217);
//          ObjectSet(tPIVOT1,OBJPROP_WIDTH,myBoxWidth);  
          ObjectSet(tPIVOT1,OBJPROP_COLOR,ColorHeading);  
      } 
      else
      {
         ObjectMove(tPIVOT1,0,Time[myBars],myLower);
      }

  if (ObjectFind(tPIVOT2) != 0)
      {
          ObjectCreate(tPIVOT2,OBJ_ARROW,0,Time[nLL],myLower);
          ObjectSet(tPIVOT2,OBJPROP_ARROWCODE,217);
//          ObjectSet(tPIVOT2,OBJPROP_WIDTH,myBoxWidth);  
          ObjectSet(tPIVOT2,OBJPROP_COLOR,ColorLower);  
      } 
      else
      {
         ObjectMove(tPIVOT2,0,Time[nLL],myLower);
      }
      
   string RRRP01 = "TRO SR RR("+myBars+")." + myShift ;
   
   if( UseBias ) { RRRP01 = RRRP01 + "  Bias ON" ; }     

/*
   ObjectCreate(rec1, OBJ_RECTANGLE, WindowToUse, Xdist_line, 0,50,1300);
   ObjectSet(rec1, OBJPROP_COLOR, myColorBG);   
   ObjectSet(rec1, OBJPROP_CORNER, Corner_pivots);
   ObjectSet(rec1, OBJPROP_BACK, true );  
*/   
   
     

   ObjectCreate(rec1, OBJ_LABEL, WindowToUse, 0, 0,0,0);
   ObjectSetText(rec1, "лллл" ,100, FontToUse , myColorBG); // "лллл"
   ObjectSet(rec1, OBJPROP_CORNER, Corner_pivots);
   ObjectSet(rec1, OBJPROP_XDISTANCE, Xdist_line);
   ObjectSet(rec1, OBJPROP_YDISTANCE, 0+myChartY);
   ObjectSet(rec1, OBJPROP_BACK, true );    
   


   ObjectCreate(rec2, OBJ_LABEL, WindowToUse, 0, 0,0,0);
   ObjectSetText(rec2, "лллл" ,100, FontToUse , myColorBG); // "лллл"
   ObjectSet(rec2, OBJPROP_CORNER, Corner_pivots);
   ObjectSet(rec2, OBJPROP_XDISTANCE, Xdist_line);
   ObjectSet(rec2, OBJPROP_YDISTANCE, 90+myChartY);
   ObjectSet(rec2, OBJPROP_BACK, true );    
     


   ObjectCreate(rec3, OBJ_LABEL, WindowToUse, 0, 0,0,0);
   ObjectSetText(rec3, "лллл" ,100, FontToUse , myColorBG); // "лллл"
   ObjectSet(rec3, OBJPROP_CORNER, Corner_pivots);
   ObjectSet(rec3, OBJPROP_XDISTANCE, Xdist_line);
   ObjectSet(rec3, OBJPROP_YDISTANCE, 150+myChartY);
   ObjectSet(rec3, OBJPROP_BACK, true );    
            

   ObjectCreate("RRRP", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("RRRP", RRRP01 ,9, "Verdana", ColorHeading);
   ObjectSet("RRRP", OBJPROP_CORNER, Corner_pivots);
   ObjectSet("RRRP", OBJPROP_XDISTANCE, 10+Xdist_pivots);
   ObjectSet("RRRP", OBJPROP_YDISTANCE, Ydist_pivots);
   
   ObjectCreate("line5RRRP", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("line5RRRP","--------------------------------------",9, "Verdana", ColorHeading);
   ObjectSet("line5RRRP", OBJPROP_CORNER, Corner_line);
   ObjectSet("line5RRRP", OBJPROP_XDISTANCE, Xdist_line);
   ObjectSet("line5RRRP", OBJPROP_YDISTANCE, Ydist_line5);
   
   ObjectCreate("R3_lRRRP", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("R3_lRRRP","Resistance["+nHH+"]",9, "Verdana", ColorUpper);
   ObjectSet("R3_lRRRP", OBJPROP_CORNER, Corner_text);
   ObjectSet("R3_lRRRP", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("R3_lRRRP", OBJPROP_YDISTANCE, Ydist_R3);

   ObjectCreate("R3_vRRRP", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("R3_vRRRP"," "+DoubleToStr(myUpper,dig),9, "Verdana", ColorUpper);
   ObjectSet("R3_vRRRP", OBJPROP_CORNER, Corner_vRRRP);
   ObjectSet("R3_vRRRP", OBJPROP_XDISTANCE, Xdist_vRRRP);
   ObjectSet("R3_vRRRP", OBJPROP_YDISTANCE, Ydist_R3);
   
   ObjectCreate("R2_lRRRP", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("R2_lRRRP","Go Short",9, "Verdana", ColorShort);
   ObjectSet("R2_lRRRP", OBJPROP_CORNER, Corner_text);
   ObjectSet("R2_lRRRP", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("R2_lRRRP", OBJPROP_YDISTANCE, Ydist_R2);
   
   ObjectCreate("R2_vRRRP", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("R2_vRRRP"," "+DoubleToStr(goShort,dig),9, "Verdana", ColorShort);
   ObjectSet("R2_vRRRP", OBJPROP_CORNER, Corner_vRRRP);
   ObjectSet("R2_vRRRP", OBJPROP_XDISTANCE, Xdist_vRRRP);
   ObjectSet("R2_vRRRP", OBJPROP_YDISTANCE, Ydist_R2);
   

   ObjectCreate("R1_lRRRP", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("R1_lRRRP","Go Long",9, "Verdana", ColorLong );
   ObjectSet("R1_lRRRP", OBJPROP_CORNER, Corner_text);
   ObjectSet("R1_lRRRP", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("R1_lRRRP", OBJPROP_YDISTANCE, Ydist_R1);
   
   ObjectCreate("R1_vRRRP", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("R1_vRRRP"," "+DoubleToStr(goLong,dig),9, "Verdana", ColorLong);
   ObjectSet("R1_vRRRP", OBJPROP_CORNER, Corner_vRRRP);
   ObjectSet("R1_vRRRP", OBJPROP_XDISTANCE, Xdist_vRRRP);
   ObjectSet("R1_vRRRP", OBJPROP_YDISTANCE, Ydist_R1);
   
   ObjectCreate("Pivot_lRRRP", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("Pivot_lRRRP","Support["+nLL+"]",9, "Verdana", ColorLower);
   ObjectSet("Pivot_lRRRP", OBJPROP_CORNER, Corner_text);
   ObjectSet("Pivot_lRRRP", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("Pivot_lRRRP", OBJPROP_YDISTANCE, Ydist_PV);
   
   ObjectCreate("Pivot_vRRRP", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("Pivot_vRRRP"," "+DoubleToStr(myLower,dig),9, "Verdana", ColorLower);
   ObjectSet("Pivot_vRRRP", OBJPROP_CORNER, Corner_vRRRP);
   ObjectSet("Pivot_vRRRP", OBJPROP_XDISTANCE, Xdist_vRRRP);
   ObjectSet("Pivot_vRRRP", OBJPROP_YDISTANCE, Ydist_PV);   
 
   string label05 = "RISK<"+ DoubleToStr(MaxRisk/point,0) + ">" ;
   
   ObjectCreate("X05_LabelRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X05_LabelRRR", label05 ,9, "Verdana", ColorHeading );
   ObjectSet("X05_LabelRRR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X05_LabelRRR", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X05_LabelRRR", OBJPROP_YDISTANCE, Ydist_X05);
   
   ObjectCreate("X05_ValueRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X05_ValueRRR"," "+DoubleToStr(risk/point,0),9, "Verdana", ColorHeading);
   ObjectSet("X05_ValueRRR", OBJPROP_CORNER, Corner_vRRRP);
   ObjectSet("X05_ValueRRR", OBJPROP_XDISTANCE, Xdist_vRRRP);
   ObjectSet("X05_ValueRRR", OBJPROP_YDISTANCE, Ydist_X05);


   string label06 = "REWARD<"+ DoubleToStr(MaxReward/point,0) + ">" ;
       
   ObjectCreate("X06_LabelRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X06_LabelRRR",label06,9, "Verdana", ColorHeading );
   ObjectSet("X06_LabelRRR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X06_LabelRRR", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X06_LabelRRR", OBJPROP_YDISTANCE, Ydist_X06);
   
   ObjectCreate("X06_ValueRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X06_ValueRRR"," "+DoubleToStr(reward/point,0),9, "Verdana", ColorHeading);
   ObjectSet("X06_ValueRRR", OBJPROP_CORNER, Corner_vRRRP);
   ObjectSet("X06_ValueRRR", OBJPROP_XDISTANCE, Xdist_vRRRP);
   ObjectSet("X06_ValueRRR", OBJPROP_YDISTANCE, Ydist_X06);


   string label07 = "RATIO <"+ DoubleToStr(MaxRatio,2) + ">" ;

   ObjectCreate("X07_LabelRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X07_LabelRRR",label07,9, "Verdana", ColorRatio );
   ObjectSet("X07_LabelRRR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X07_LabelRRR", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X07_LabelRRR", OBJPROP_YDISTANCE, Ydist_X07);
   
   ObjectCreate("X07_ValueRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X07_ValueRRR"," 1:"+DoubleToStr(ratio,2),9, "Verdana", ColorRatio);
   ObjectSet("X07_ValueRRR", OBJPROP_CORNER, Corner_vRRRP);
   ObjectSet("X07_ValueRRR", OBJPROP_XDISTANCE, Xdist_vRRRP);
   ObjectSet("X07_ValueRRR", OBJPROP_YDISTANCE, Ydist_X07);

   string label08 = "R="+ DoubleToStr(range/point,0) + " Fib %Ret" ;

   ObjectCreate("X08_LabelRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X08_LabelRRR",label08 ,9, "Verdana", ColorHeading );
   ObjectSet("X08_LabelRRR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X08_LabelRRR", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X08_LabelRRR", OBJPROP_YDISTANCE, Ydist_X08);
   
   ObjectCreate("X08_ValueRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X08_ValueRRR"," "+DoubleToStr(fibpct,2),9, "Verdana", ColorHeading);
   ObjectSet("X08_ValueRRR", OBJPROP_CORNER, Corner_vRRRP);
   ObjectSet("X08_ValueRRR", OBJPROP_XDISTANCE, Xdist_vRRRP);
   ObjectSet("X08_ValueRRR", OBJPROP_YDISTANCE, Ydist_X08);


   ObjectCreate("X09_LabelRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X09_LabelRRR","Lg P/L",9, "Verdana", ColorHeading );
   ObjectSet("X09_LabelRRR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X09_LabelRRR", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X09_LabelRRR", OBJPROP_YDISTANCE, Ydist_X09);

if( LongPL >= 0 ) { ColorLongPL = Green ; } else { ColorLongPL = Red ; }
   
   ObjectCreate("X09_ValueRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X09_ValueRRR"," "+DoubleToStr(LongPL,0),9, "Verdana", ColorLongPL);
   ObjectSet("X09_ValueRRR", OBJPROP_CORNER, Corner_vRRRP);
   ObjectSet("X09_ValueRRR", OBJPROP_XDISTANCE, Xdist_vRRRP);
   ObjectSet("X09_ValueRRR", OBJPROP_YDISTANCE, Ydist_X09);

   ObjectCreate("X10_LabelRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X10_LabelRRR","Sh P/L",9, "Verdana", ColorHeading );
   ObjectSet("X10_LabelRRR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X10_LabelRRR", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X10_LabelRRR", OBJPROP_YDISTANCE, Ydist_X10);

if( ShortPL >= 0 ) { ColorShortPL = Green ; } else { ColorShortPL = Red ; }
   
   ObjectCreate("X10_ValueRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X10_ValueRRR"," "+DoubleToStr(ShortPL,0),9, "Verdana", ColorShortPL);
   ObjectSet("X10_ValueRRR", OBJPROP_CORNER, Corner_vRRRP);
   ObjectSet("X10_ValueRRR", OBJPROP_XDISTANCE, Xdist_vRRRP);
   ObjectSet("X10_ValueRRR", OBJPROP_YDISTANCE, Ydist_X10);


   Bias1_Msg = tBias1_Peroid + " Bias " + Bias1_Msg ;

   ObjectCreate("X11_LabelRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X11_LabelRRR", Bias1_Msg ,9, "Verdana", Bias1_Color );
   ObjectSet("X11_LabelRRR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X11_LabelRRR", OBJPROP_XDISTANCE, -10+Xdist_text);
   ObjectSet("X11_LabelRRR", OBJPROP_YDISTANCE, Ydist_X11);
   
   ObjectCreate("X11_ValueRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X11_ValueRRR"," "+DoubleToStr(Bias1_Diff / point ,0),9, "Verdana", Bias1_Color);
   ObjectSet("X11_ValueRRR", OBJPROP_CORNER, Corner_vRRRP);
   ObjectSet("X11_ValueRRR", OBJPROP_XDISTANCE, Xdist_vRRRP);
   ObjectSet("X11_ValueRRR", OBJPROP_YDISTANCE, Ydist_X11);

   string OpenMsg = tBias1_Peroid + " Time: " + yymmddms ;

   ObjectCreate("X12_LabelRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X12_LabelRRR", OpenMsg ,9, "Verdana", Bias1_Color );
   ObjectSet("X12_LabelRRR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X12_LabelRRR", OBJPROP_XDISTANCE, -45+Xdist_text);
   ObjectSet("X12_LabelRRR", OBJPROP_YDISTANCE, Ydist_X12);
   
Bias2_Msg = tBias2_Peroid + " Bias " + Bias2_Msg ;

   ObjectCreate("X13_LabelRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X13_LabelRRR", Bias2_Msg ,9, "Verdana", Bias2_Color );
   ObjectSet("X13_LabelRRR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X13_LabelRRR", OBJPROP_XDISTANCE, -10+Xdist_text);
   ObjectSet("X13_LabelRRR", OBJPROP_YDISTANCE, Ydist_X13);
   
   ObjectCreate("X13_ValueRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X13_ValueRRR"," "+DoubleToStr(Bias2_Diff / point ,0),9, "Verdana", Bias2_Color);
   ObjectSet("X13_ValueRRR", OBJPROP_CORNER, Corner_vRRRP);
   ObjectSet("X13_ValueRRR", OBJPROP_XDISTANCE, Xdist_vRRRP);
   ObjectSet("X13_ValueRRR", OBJPROP_YDISTANCE, Ydist_X13);


    
   ObjectCreate("X14_LabelRRR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X14_LabelRRR", Trade_Msg ,9, "Verdana", Trade_Color );
   ObjectSet("X14_LabelRRR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X14_LabelRRR", OBJPROP_XDISTANCE, -10+Xdist_text);
   ObjectSet("X14_LabelRRR", OBJPROP_YDISTANCE, Ydist_X14);
   


} 


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

void DoShowLabels()
{

	if(ObjectFind(tRes0) == -1)
		ObjectCreate(tRes0,OBJ_FIBO,0,StartTime,myUpper+range,StartTime,myUpper);
	else
	{
		ObjectSet(tRes0,OBJPROP_TIME2, StartTime);
		ObjectSet(tRes0,OBJPROP_TIME1, StartTime);
		ObjectSet(tRes0,OBJPROP_PRICE1,myUpper+range);
		ObjectSet(tRes0,OBJPROP_PRICE2,myUpper);
	}
   ObjectSet(tRes0,OBJPROP_LEVELCOLOR,ColorUpper);
   ObjectSet(tRes0,OBJPROP_FIBOLEVELS,1);
   ObjectSet(tRes0,OBJPROP_FIRSTLEVEL+0,0.0);	
   ObjectSet(tRes0,OBJPROP_RAY,true);
   ObjectSet(tRes0,OBJPROP_BACK,true);
   if(Show.Labels) ObjectSetFiboDescription(tRes0,0, DoubleToStr(myUpper,digits)+ " RES  "); 

		if(ObjectFind(tSup0) == -1)
			ObjectCreate(tSup0,OBJ_FIBO,0,StartTime,myLower-range,StartTime+PERIOD_H4*60,myLower);
		else
		{
			ObjectSet(tSup0,OBJPROP_TIME2, StartTime);
			ObjectSet(tSup0,OBJPROP_TIME1, StartTime);
			ObjectSet(tSup0,OBJPROP_PRICE1,myUpper);
			ObjectSet(tSup0,OBJPROP_PRICE2,myLower);
		}
   	ObjectSet(tSup0,OBJPROP_LEVELCOLOR,ColorLower); 
   	ObjectSet(tSup0,OBJPROP_FIBOLEVELS,1);
   
   	ObjectSet(tSup0,OBJPROP_FIRSTLEVEL+0,0.000);	
   	if(Show.Labels) ObjectSetFiboDescription(tSup0,0,DoubleToStr(myLower,digits)+ " SUP  "); 

   	ObjectSet(tSup0,OBJPROP_RAY,true);
   	ObjectSet(tSup0,OBJPROP_BACK,true);
   	
   	
  ObjectDelete(rPiv1);   // delete trigger line
  ObjectDelete(rPiv2);   // delete trigger line 
      
      
  if( OKtoShort )
  {     
		if(ObjectFind(rPiv1) == -1)
			ObjectCreate(rPiv1,OBJ_FIBO,0,StartTime,myUpper,StartTime+PERIOD_H4*60,myLower);
		else
		{
			ObjectSet(rPiv1,OBJPROP_TIME2, StartTime);
			ObjectSet(rPiv1,OBJPROP_TIME1, StartTime);
			ObjectSet(rPiv1,OBJPROP_PRICE1,myUpper);
			ObjectSet(rPiv1,OBJPROP_PRICE2,myLower);
		}
   	ObjectSet(rPiv1,OBJPROP_LEVELCOLOR,ColorShort); 
   	ObjectSet(rPiv1,OBJPROP_FIBOLEVELS,1);
   
   	ObjectSet(rPiv1,OBJPROP_FIRSTLEVEL+0,1-pvpct);	
   	if(Show.Labels) ObjectSetFiboDescription(rPiv1,0,DoubleToStr(goShort,digits)+ " go Short  "); 

   	ObjectSet(rPiv1,OBJPROP_RAY,true);
   	ObjectSet(rPiv1,OBJPROP_BACK,true);
  }
  
  if( OKtoLong )
  {     
		if(ObjectFind(rPiv2) == -1)
			ObjectCreate(rPiv2,OBJ_FIBO,0,StartTime,myUpper,StartTime+PERIOD_H4*60,myLower);
		else
		{
			ObjectSet(rPiv2,OBJPROP_TIME2, StartTime);
			ObjectSet(rPiv2,OBJPROP_TIME1, StartTime);
			ObjectSet(rPiv2,OBJPROP_PRICE1,myUpper);
			ObjectSet(rPiv2,OBJPROP_PRICE2,myLower);
		}
   	ObjectSet(rPiv2,OBJPROP_LEVELCOLOR,ColorLong); 
   	ObjectSet(rPiv2,OBJPROP_FIBOLEVELS,2);
   
   	ObjectSet(rPiv2,OBJPROP_FIRSTLEVEL+0,pvpct);	
   	if(Show.Labels) ObjectSetFiboDescription(rPiv2,0,DoubleToStr(goLong,digits)+ " go Long  "); 

   	ObjectSet(rPiv2,OBJPROP_RAY,true);
   	ObjectSet(rPiv2,OBJPROP_BACK,true);
  }
  
  	
}
//+------------------------------------------------------------------+ 
void DoShowOpen()
{
 
if(ObjectFind("DayTimeClose")==-1) {  ObjectCreate  ("DayTimeOpen",OBJ_VLINE,0,r,0);  }                             
 else                              {  ObjectSet     ("DayTimeOpen",OBJPROP_TIME1,r);  }
                   
if(ObjectFind("DayOpen")==-1) {ObjectCreate("DayOpen",OBJ_HLINE,0,0,Open[cd]); }                                      
else                          {   ObjectSet("DayOpen",OBJPROP_PRICE1,Open[cd]); }

 
                              ObjectSet     ("DayTimeOpen",OBJPROP_COLOR,Bias1_Color);
                              ObjectSet     ("DayOpen",OBJPROP_COLOR,Bias1_Color);                             
                              ObjectSet     ("DayOpen",OBJPROP_STYLE,Open_Line_Style);        
}



//+------------------------------------------------------------------+ 
void DoShowAsk()
{
 
 

      ObjectDelete(tAsk);
      ObjectCreate(tAsk,OBJ_HLINE,0,0,0);
      ObjectSet(tAsk,OBJPROP_COLOR,iColorAsk);
      ObjectSet(tAsk,OBJPROP_STYLE,Ask_Line_Style);
      
      ObjectMove(tAsk,0,Time[0],Ask); 
      
}

//+------------------------------------------------------------------+ 
void DoShowFibs()
{
 
 

      ObjectDelete(fib5);
      ObjectCreate(fib5,OBJ_HLINE,0,0,0);
      ObjectSet(fib5,OBJPROP_COLOR,iColor5);
      ObjectSet(fib5,OBJPROP_STYLE,Fib_Line_Style);
 

      ObjectDelete(fib4);
      ObjectCreate(fib4,OBJ_HLINE,0,0,0);
      ObjectSet(fib4,OBJPROP_COLOR,iColor4);
      ObjectSet(fib4,OBJPROP_STYLE,Fib_Line_Style);
 

      ObjectDelete(fib3);
      ObjectCreate(fib3,OBJ_HLINE,0,0,0);
      ObjectSet(fib3,OBJPROP_COLOR,iColor3);
      ObjectSet(fib3,OBJPROP_STYLE,Fib_Line_Style);
      

      ObjectDelete(fib2);
      ObjectCreate(fib2,OBJ_HLINE,0,0,0);
      ObjectSet(fib2,OBJPROP_COLOR,iColor2);
      ObjectSet(fib2,OBJPROP_STYLE,Fib_Line_Style);
 


      ObjectDelete(fib1);
      ObjectCreate(fib1,OBJ_HLINE,0,0,0);
      ObjectSet(fib1,OBJPROP_COLOR,iColor1);
      ObjectSet(fib1,OBJPROP_STYLE,Fib_Line_Style);
  
      ObjectMove(fib5,0,Time[0],xfb5);
 
      ObjectMove(fib4,0,Time[0],xfb4);
 
      ObjectMove(fib3,0,Time[0],xfb3);      
 
      ObjectMove(fib2,0,Time[0],xfb2);
 
      ObjectMove(fib1,0,Time[0],xfb1);
            
            
}

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

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);
}

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

/*






double  _Open = iOpen(NULL,BiasPeriod1,0);

string sTimeCurrent = TimeToStr(TimeCurrent() );
string svar1 = TimeToStr(var1 );

Comment(

"cd.... " , cd , "\n" ,  
"Server.... " , sTimeCurrent , "\n" ,
"yymmddms.... " , yymmddms , "\n" , 
"svar1.... " , svar1 , "\n" ,  
"r.... " , r , "\n" ,  
 
"Bias1_Open = ", DoubleToStr( Bias1_Open, Digits), "\n",
" _Open = ", DoubleToStr( _Open, Digits), "\n",
"") ;

Comment(
"goLong = ", DoubleToStr( goLong, Digits), "\n",
"goShort = ", DoubleToStr( goShort, Digits), "\n",
"close = ", DoubleToStr( close, Digits), "\n",
"LongPL = ", DoubleToStr( LongPL, Digits), "\n",
"ShortPL = ", DoubleToStr( ShortPL, Digits), "\n",
"") ;



Comment(
"myUpper = ", DoubleToStr( myUpper, Digits), "\n",
"myLower = ", DoubleToStr( myLower, Digits), "\n",
"reward = ", DoubleToStr( reward, Digits), "\n",
"risk = ", DoubleToStr( risk, Digits), "\n",
"ratio = ", DoubleToStr( ratio, Digits), "\n",
"pivot = ", DoubleToStr( pivot, Digits), "\n",
"") ; 


      ObjectDelete(fib5);
      ObjectCreate(fib5,OBJ_HLINE,0,0,0);
      ObjectSet(fib5,OBJPROP_COLOR,iColor5);
      ObjectSet(fib5,OBJPROP_STYLE,Fib_Line_Style);
      ObjectMove(fib5,0,Time[0],xfb5);

      ObjectDelete(fib4);
      ObjectCreate(fib4,OBJ_HLINE,0,0,0);
      ObjectSet(fib4,OBJPROP_COLOR,iColor4);
      ObjectSet(fib4,OBJPROP_STYLE,Fib_Line_Style);
      ObjectMove(fib4,0,Time[0],xfb4);

      ObjectDelete(fib3);
      ObjectCreate(fib3,OBJ_HLINE,0,0,0);
      ObjectSet(fib3,OBJPROP_COLOR,iColor3);
      ObjectSet(fib3,OBJPROP_STYLE,Fib_Line_Style);
      ObjectMove(fib3,0,Time[0],xfb3);      

      ObjectDelete(fib2);
      ObjectCreate(fib2,OBJ_HLINE,0,0,0);
      ObjectSet(fib2,OBJPROP_COLOR,iColor2);
      ObjectSet(fib2,OBJPROP_STYLE,Fib_Line_Style);
      ObjectMove(fib2,0,Time[0],xfb2);


      ObjectDelete(fib1);
      ObjectCreate(fib1,OBJ_HLINE,0,0,0);
      ObjectSet(fib1,OBJPROP_COLOR,iColor1);
      ObjectSet(fib1,OBJPROP_STYLE,Fib_Line_Style);
      ObjectMove(fib1,0,Time[0],xfb1);
      
*/