Witam.
Wolalbym cos bez sema.
Moze uda sie zmodyfikowac ten wskaznik, zeby zamiast pokazywac gdzie w danej chwili wystepuje
Kod: Zaznacz cały
//----
#property indicator_chart_window
extern int myChartX   = 10 ;
extern int myChartY   = 100 ;
 int myCorner   = 1 ;
extern string myFont  = "Courier New" ;
extern int myFontSize = 12 ;
extern string Symbols      = "AUDJPY;AUDUSD;EURGBP;EURJPY;EURUSD;GBPCHF;GBPJPY;GBPUSD;NZDUSD;USDCAD;USDCHF;USDJPY" ;
extern int       myPeriod       = 0 ;
//extern double    myThreshold = 20;  
 
//extern int  iArrow      = 254;
extern color colorHD =    Orange ;
extern color  colorBUY   = Lime;
//extern color  colorSELL  = Red ; 
extern color  colorSHORT = Crimson;
//extern color  colorCOVER = Green ; 
extern color  colorWAIT  = DimGray ;
string symbol, tChartPeriod, ShortName, tsymbol ;  
int     digits, period, win, digits2, n, j, i, w; 
 
double point, point2, value, spread  ;
string lbl[15], lbl2[15], pArrow, D1Arrow, W1Arrow, MNArrow;
color pColor = Blue ;
//---- PipsToOpen
string Indicator_Name = "MPRATBZ:" ;
int Objs = 0;
//+------------------------------------------------------------------+ 
int     ind_bufferOp[] ;
string shortName ;
int    cpairsLenH;
int    cpairsLenV;
int    shortLength;
int    ctimesLen;
string cpairsh[];
string cpairsv[];
int    aTimes[];
string addition  = "";
string FontToUse = "Terminal";
 
string  sDailyOpen , tMessage, tAlert ;  
int      LastAOFS ;
double   DailyOpen ;
string ArrowReverse   ; 
string ArrowDemand  ;  
string ArrowSupply   ;  
string ArrowWarning   ;  
string ArrowNoSignal   ;  
string theArrow, theArrowDet, theArrowCharge;
color   theColor, theColorDet, theColorCharge, theColorTR, theColorRAT;
 
string ArrowHeadRt =  "Ø" ; // 216 up arrow head
string ArrowHeadUp =  "Ù" ; // 217 up arrow head
string ArrowHeadDn =  "Ú" ; // 218 up arrow head 
double    C, O, H, L  , C1, O1, H1, L1, C2, O2 ;
 
int UseFontSize = 12,  HH, HL, LH, LL, yy,mm,dd  ; 
int x001, x002, x003, x004, x005, x006, x007, x008, x009 ; 
double close, W1_Open, D1_Low, D1_High;
double xThreshold , xSpread;
datetime Trigger ;
bool plunger = true, GREENCANDLE = false, bPRIMER = false, bCHARGE = false, bDETONATOR = false;
bool ThisBarUp, PrevBarUp, Bar2Up, AboveW1Open ;
string ArrowX, ArrowCheck ;
double RRTrigger;
//+------------------------------------------------------------------+
int init()
{
  
   ArrowX       = CharToStr(253) ;   
   ArrowCheck   = CharToStr(254) ;    
    
   if(Symbols == "") { Symbols = Symbol() ; }
   if(myPeriod == 0) { period = Period() ; } else { period = myPeriod ; }  
 
   tChartPeriod =  TimeFrameToString(period) ;
   symbol       =  Symbol() ;
   digits       =  Digits ;
   point        =  Point ;
   shortName    =  "TROMPRATBZ" ;
   win          =  0 ;
   if(digits == 5 || digits == 3) { digits2 = 0 ; point = point * 10 ; } else { digits2 = 0 ; }
   setUpStrings(cpairsh,cpairsLenH,Symbols);
   if (IsMini())   addition="m";
   if (IsDoubleDotted()) addition="..";
   else 
      if (IsDotted()) addition=".";
   
      shortLength = StringLen(shortName);
      IndicatorShortName(shortName);
   ShortName = shortName ;
if( myCorner == 0 || myCorner == 2 )
{ 
   x001 = 0 ;
   x002 = 0 ;     // pair
   x003 = 70 ;    // d1 arrow
   x004 = 110;    // message
   x005 = 80 ;   // w1 arrow
   x006 = 90;    // mn arrow 
   x007 = 90 ;     
}
else
{
   x001 = 0 ;
   x002 = 120 ;   // pair
   x003 = 30 ;    //   arrow
   x004 = 20 ;    // arrow
   x005 = 10 ;   //      
   x006 = 50 ;   //     
   x007 = 00 ; 
   x008 = 000 ;   //    
   x009 = 0 ;    //  
     
}
   deinit() ;  
   return(0);
  }
//+------------------------------------------------------------------+
void ObDeleteObjectsByPrefix(string Prefix)
  {
   int L = StringLen(Prefix);
   int i = 0; 
   while(i < ObjectsTotal())
     {
       string ObjName = ObjectName(i);
       if(StringSubstr(ObjName, 0, L) != Prefix) 
         { 
           i++; 
           continue;
         }
       ObjectDelete(ObjName);
     }
  } 
//+------------------------------------------------------------------+
int deinit()
{
 ObDeleteObjectsByPrefix(ShortName);  
 TRO() ;
return(0);
  }
 
//+------------------------------------------------------------------+
int start()
{
 
n       = 10;
j       = 0 ;
lbl[j]  = ShortName+j;
lbl2[j] = fFill(tChartPeriod + " RAT BuyZone " , 18 ) ;
DoShowHD(j, colorHD);
for (i = 0; i < cpairsLenH; i++)
{
string symbol = cpairsh[i]+addition;
      
digits = MarketInfo(symbol,MODE_DIGITS) ; 
point  = MarketInfo(symbol,MODE_POINT) ;       
spread = MarketInfo(symbol,MODE_SPREAD) ;   
xSpread = spread * point ;      
if(digits == 5 || digits == 3) { digits  = digits - 1 ; point = point * 10 ; }  
 
DoWork( symbol, period  )  ;  
         
j       = j + 1 ;
if(symbol != Symbol()) { tsymbol = symbol ; } else {tsymbol = "*" + symbol;} 
//if( Show.Price ) { tsymbol = tsymbol + " " + fFill(DoubleToStr(close, digits),6)  ; } 
lbl[j]  = ShortName+j;
lbl2[j] = tsymbol    ;
DoShow(j, colorHD); 
  
  
}
   string TimeLeft ;
	double ii;
   int m,s,k,h,d;
   m=iTime(symbol,period,0)+period*60-TimeCurrent();
   ii=m/60.0;
   s=m%60;
   m=(m-m%60)/60;
 
   
   h=m/60;
   m=m-(h*60);
   d=h/24;
   h=h-(d*24);
   
   if(period <= PERIOD_D1) { TimeLeft = "Ends: " +h+"h "  +m+"m "+s+ "s" ; }
   else { TimeLeft = "Ends: " +d+"d " +h+"h "  +m+"m "  ; } 
   
j       = j + 1 ;
lbl[j]  = ShortName+j;
lbl2[j] = fFill(TimeLeft , 18) ;
DoShowHD(j, colorHD); 
   WindowRedraw() ;
   
return(0);
}
//+------------------------------------------------------------------+
  
void DoShowHD( int u, color dsColor )
{
ObjectCreate(lbl[u],23,0,Time[0],PRICE_CLOSE);
ObjectSet(lbl[u], OBJPROP_CORNER, myCorner );
ObjectSet(lbl[u],OBJPROP_XDISTANCE, x001 + myChartX);
ObjectSet(lbl[u],OBJPROP_YDISTANCE,n+myChartY);
ObjectSetText(lbl[u],lbl2[u],myFontSize,myFont,dsColor);
n = n+20;
return(0);
}  
//+------------------------------------------------------------------+
  
void DoShow( int u, color dsColor )
{
ObjectCreate(lbl[u],23,0,Time[0],PRICE_CLOSE);
ObjectSet(lbl[u], OBJPROP_CORNER, myCorner );
ObjectSet(lbl[u],OBJPROP_XDISTANCE, x002+myChartX);
ObjectSet(lbl[u],OBJPROP_YDISTANCE,n+myChartY);
ObjectSetText(lbl[u],lbl2[u],myFontSize,myFont,theColorRAT);
if( u > 0)
{
 
   string Lname = lbl[u]+"rrtrig" ;
   string sRT = DoubleToStr( close, digits );
   ObjectDelete(Lname);
   ObjectCreate(Lname, 23,0,Time[0],PRICE_CLOSE);
   ObjectSetText(Lname, sRT, myFontSize,myFont , theColorDet);
   ObjectSet(Lname, OBJPROP_CORNER, myCorner);
   ObjectSet(Lname, OBJPROP_XDISTANCE, x006+myChartX );
   ObjectSet(Lname, OBJPROP_YDISTANCE, n+myChartY);  
     Lname = lbl[u]+"ARROW" ;
   ObjectDelete(Lname);
   ObjectCreate(Lname, 23,0,Time[0],PRICE_CLOSE);
   ObjectSetText(Lname, theArrow, 12, "WingDings", theColor);
   ObjectSet(Lname, OBJPROP_CORNER, myCorner);
   ObjectSet(Lname, OBJPROP_XDISTANCE, x003+myChartX );
   ObjectSet(Lname, OBJPROP_YDISTANCE, n+myChartY);  
     Lname = lbl[u]+"ARROWcharge" ;
   ObjectDelete(Lname);
   ObjectCreate(Lname, 23,0,Time[0],PRICE_CLOSE);
   ObjectSetText(Lname, theArrowCharge, 12, "WingDings", theColorCharge);
   ObjectSet(Lname, OBJPROP_CORNER, myCorner);
   ObjectSet(Lname, OBJPROP_XDISTANCE, x004+myChartX );
   ObjectSet(Lname, OBJPROP_YDISTANCE, n+myChartY);  
   
     Lname = lbl[u]+"ARROWdet" ;
   ObjectDelete(Lname);
   ObjectCreate(Lname, 23,0,Time[0],PRICE_CLOSE);
   ObjectSetText(Lname, theArrowDet, 12, "WingDings", theColorDet);
   ObjectSet(Lname, OBJPROP_CORNER, myCorner);
   ObjectSet(Lname, OBJPROP_XDISTANCE, x005+myChartX );
   ObjectSet(Lname, OBJPROP_YDISTANCE, n+myChartY);     
   
   
/* 
      Lname = lbl[u]+"price" ;
   
  ObjectDelete(Lname);
   ObjectCreate(Lname, 23,0,Time[0],PRICE_CLOSE);
   ObjectSetText(Lname, tAlert , myFontSize,myFont, theColor );
   ObjectSet(Lname, OBJPROP_CORNER, myCorner);
   ObjectSet(Lname, OBJPROP_XDISTANCE, x004+ myChartX );
   ObjectSet(Lname, OBJPROP_YDISTANCE, n+myChartY);  
*/
 
}
n = n+20;
}   
 
//+------------------------------------------------------------------+
 
bool   IsMini()         { return(StringFind(Symbol(),"m")  > -1); }
bool   IsDoubleDotted() { return(StringFind(Symbol(),"..") > -1); }
bool   IsDotted()       { return(StringFind(Symbol(),".")  > -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);
}
//+------------------------------------------------------------------+
string StringUpperCase(string str)
{
   string   s = str;
   int      lenght = StringLen(str) - 1;
   int      char;
   
   while(lenght >= 0)
      {
         char = StringGetChar(s, lenght);
         
         //
         //
         //
         //
         //
         
         if((char > 96 && char < 123) || (char > 223 && char < 256))
                  s = StringSetChar(s, lenght, char - 32);
         else 
              if(char > -33 && char < 0)
                  s = StringSetChar(s, lenght, char + 224);
         lenght--;
   }
   return(s);
}
//+------------------------------------------------------------------+ 
void setUpStrings(string& array[],int& length, string source)
{
   source = StringUpperCase(StringTrimLeft(StringTrimRight(source)));
   if (StringSubstr(source,StringLen(source)-1,1) != ";")
                    source = StringConcatenate(source,";");
   //
   //
   //
   //
   //
   
   int  s = 0;
   int  i = StringFind(source,";",s);
   string current;
      while (i > 0)
      {
         current = StringSubstr(source,s,i-s);
         ArrayResize(array,ArraySize(array)+1);
                     array[ArraySize(array)-1] = current;
                     s = i + 1;
                     i = StringFind(source,";",s);
      }
   length = ArraySize(array);
}
 
  
//+------------------------------------------------------------------+
void DoWork( string myPair, int myPeriod )  
{
 
 
// xThreshold = myThreshold * point ; 
W1_Open = iOpen(myPair, PERIOD_W1, 0) ;  
 
D1_High = iHigh(myPair, PERIOD_D1, 0) ;  
D1_Low  = iLow(myPair, PERIOD_D1, 0) ;         
      
close  = iClose(myPair, myPeriod, 0) ; 
O  = iOpen(myPair, myPeriod, 0) ;          
H  = iHigh(myPair, myPeriod, 0) ;   
L  = iLow(myPair, myPeriod, 0) ;   
         
O1 = iOpen(myPair, myPeriod, 1) ;           
C1 = iClose(myPair, myPeriod, 1) ;           
H1 = iHigh(myPair, myPeriod, 1) ;   
L1 = iLow(myPair, myPeriod, 1) ;    
O2 = iOpen(myPair, myPeriod, 2) ;           
C2 = iClose(myPair, myPeriod, 2) ;    
 
AboveW1Open = close > W1_Open ;
 
ThisBarUp = close > O ;
PrevBarUp = C1 > O1; 
Bar2Up    = C2 > O2;         
         
theArrow = ArrowX ;  
        
   while(true)
   {
      if ( Bar2Up )  { theColor = colorBUY;   RRTrigger = H1 ;     bPRIMER = true ; break ;}  
      if ( !Bar2Up ) { theColor = colorSHORT; RRTrigger = L1 ;     bPRIMER = true ; break ;}     
                       theColor = colorWAIT;  theArrow = ArrowX ;  RRTrigger = 0.0 ;  
      break ;
   } // while                      
       
              
theArrowCharge = ArrowX ;         
         
   while(true)
   {
      if ( PrevBarUp   ) { theColorCharge = colorBUY;   bCHARGE = true ;  break ;}  
      if ( !PrevBarUp  ) { theColorCharge = colorSHORT; bCHARGE = true ; break ;}     
                           theColorCharge = colorWAIT;  theArrowCharge = ArrowX ;   
   
      break ;
   } // while                      
         
         
         
   
         
   while(true)
   {
      if ( ThisBarUp  ) { theColorDet = colorBUY; bDETONATOR = true ;  break ;}  
      if ( !ThisBarUp ) { theColorDet = colorSHORT; bDETONATOR = true ; break ;}     
                          theColorDet = colorWAIT;   theArrowDet  = ArrowX ;      
      break ;
   } // while   
  
   while(true)
   {
      if ( !Bar2Up && PrevBarUp  ) { theArrow = ArrowCheck ; theArrowCharge = ArrowCheck ;    break ;}  
      if ( Bar2Up  && !PrevBarUp ) { theArrow = ArrowCheck ; theArrowCharge = ArrowCheck ;   break ;}     
                                   
      break ;
   } // while    
  
theArrowDet = ArrowX ; 
       
   while(true)
   {
      if ( AboveW1Open  && !Bar2Up && PrevBarUp  && ThisBarUp  ) { tAlert = "RAT BZ BUY   "  ; theColorRAT = colorBUY;   theArrowDet = ArrowCheck ; bDETONATOR = true ;  break ;}  
      if ( !AboveW1Open && Bar2Up  && !PrevBarUp && !ThisBarUp ) { tAlert = "RAT BZ SHORT "  ; theColorRAT = colorSHORT; theArrowDet = ArrowCheck ; bDETONATOR = true ; break ;}     
                                                                                            theColorRAT = colorWAIT;  theArrowDet  = ArrowX ;    
      break ;
   } // while   
         
   
if(theArrowDet  != ArrowX  )
{
   theColorTR = theColor ;
   
   if ( plunger && Trigger != Time[0]   ) 
   {
      Trigger = Time[0] ;  
     
      plunger = false ; 
      bPRIMER = false;
      bCHARGE = false; 
      bDETONATOR = false;        
   }   
   
}   
else
{
   plunger    = true ;
   theColorTR = colorWAIT ;
   tAlert     = "RAT WAIT  " ;
}          
     
                                 
} //    
//+------------------------------------------------------------------+
string fFill(string filled, int f ) 
{
   string FILLED ;
   
   FILLED = StringSubstr(filled + "                                         ",0,f) ;
   
return(FILLED);
}
//+------------------------------------------------------------------+  
void TRO()
{   
   
   string tObjName03    = "TROTAG"  ;  
   ObjectCreate(tObjName03, OBJ_LABEL, 0, 0, 0);//HiLow LABEL
   ObjectSetText(tObjName03, CharToStr(78) , 12 ,  "Wingdings",  DimGray );
   ObjectSet(tObjName03, OBJPROP_CORNER, 3);
   ObjectSet(tObjName03, OBJPROP_XDISTANCE, 5 );
   ObjectSet(tObjName03, OBJPROP_YDISTANCE, 5 );  
}
//+------------------------------------------------------------------+
/*
if(myPair == "USDCHF" )
{    
Comment(
"myPair " , myPair , "\n" ,   
"ThisBarUp " , ThisBarUp , "\n" ,    
"PrevBarUp " , PrevBarUp , "\n" , 
"Bar2Up " , Bar2Up , "\n" ,  
"") ;     
} // if  
       
Comment(
"myPair " , myPair , "\n" ,   
"TheBuffer " , DoubleToStr(TheBuffer,Digits) , "\n" ,    
"TheBufferCharge " , DoubleToStr(TheBufferCharge,Digits) , "\n" ,   
"") ;  
  
void DoColor( double c1, double c2 )
{
if(c1 > c2 ) { pColor = colorUp ; pArrow = ArrowU; } else {
if(c1 < c2 ) { pColor = colorDn ; pArrow = ArrowD; } else { pColor = colorEq ; pArrow = ArrowR; } } 
} 
   
 
Comment(
"myPair " , myPair , "\n" ,   
"PipDiffHigh " , DoubleToStr(PipDiffHigh,Digits) , "\n" ,    
"PipDiffLow " , DoubleToStr(PipDiffLow,Digits) , "\n" ,   
"") ;  
Comment(
"arrNZD[0] " , DoubleToStr(arrNZD[0],Digits) , "\n" ,   
"arrNZD[1] " , DoubleToStr(arrNZD[1],Digits) , "\n" ,    
"arrNZD[Bars] " , DoubleToStr(arrNZD[Bars],Digits) , "\n" ,   
"") ; 
//+------------------------------------------------------------------+
string rtadjust( string rString )
{
 
 int sl = StringLen(rString) ;
 
 while(true)
 {
 
   if( sl == 5) { break ; } 
   if( sl == 4) { rString = " " + rString ; break ; }    
   if( sl == 3) { rString = "  " + rString ; break ; } 
   if( sl == 2) { rString = "   " + rString ; break ; } 
   if( sl == 1) { rString = "    " + rString ; break ; } 
    
   break ;
 }
return(rString) ;
}       
*/