FOREX MT4 INDICATORS DOWNLOAD
  • Donate to the operator
  • MT4 INDICATORS A
  • MT4 INDICATORS B
  • MT4 INDICATORS C
  • MT4 INDICATORS D
  • MT4 INDICATORS E
  • MT4 INDICATORS F
  • MT4 INDICATORS G
  • MT4 INDICATORS H
  • MT4 INDICATORS I
  • MT4 INDICATORS J
  • MT4 INDICATORS K
  • MT4 INDICATORS L
  • MT4 INDICATORS M
  • MT4 INDICATORS N
  • MT4 INDICATORS O
  • MT4 INDICATORS P
  • MT4 INDICATORS Q
  • MT4 INDICATORS R
  • MT4 INDICATORS S
  • MT4 INDICATORS T
  • MT4 INDICATORS U
  • MT4 INDICATORS V
  • MT4 INDICATORS W
  • MT4 INDICATORS X
  • MT4 INDICATORS Y
  • MT4 INDICATORS Z
  • MT4 INDICATORS NUM
  • MT4 INDICATORS SIGN

BUTTONS_SW_TRO_MODIFIED.mq4

BUTTONS_SW_TRO_MODIFIED.mq4 download link will appear after 10 seconds.


Icon

BUTTONS_SW_TRO_MODIFIED.mq4

1 file(s) 24.40 KB
Download


BUTTONS_SW_TRO_MODIFIED.mq4 Programming source code.

//+------------------------------------------------------------------+
//|  BUTTONS_TRO_MODIFIED                                            |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 0
#property strict

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

extern bool TURN_OFF    = false ;
extern bool SHOW_CANDLE_COLOR = true;  
  

extern string  sOption = "Type ALL in Symbols for all symbols ";
extern string  Symbols="ALL";
//extern string  Symbols="AUDJPY;AUDUSD;EURUSD;EURGBP;EURJPY;GBPUSD;GBPJPY;NZDUSD;USDCAD;USDCHF;USDJPY"; // List of symbols (separated by ";")
extern string  Suffix="";

extern string  UniqueID="changer";     // Indicator unique ID

extern int     ButtonsInARow = 14;      // Buttons in a horizontal row
extern int     Corner        = 2;      // Corner
extern int     XShift        = 35;    // Horizontal shift
extern int     YShift        = 20;     // Vertical shift
extern int     XSize         = 65;     // Width of buttons
extern int     YSize         = 16;     // Height of buttons
extern int     FSize         = 8;     // Font size
extern string  FontType      = "Consolas" ; // Font
extern color   Bcolor=clrLightGray;        // Button color
extern color   Dcolor=clrDarkSlateBlue;        // Button border color
extern color   Tncolor=clrBlack;       // Text color - normal
extern color   Sncolor= clrBlue;    // Text color - selected
extern bool    Transparent= true;     // Transparent buttons?
extern color colorUp       = Lime ;
extern color colorDn       = Red ; 


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

string aSymbols[], tSymbols, xySymbol,yxSymbol,symbol  ;
string CurrencyTable[] = {"AUD","CAD","CHF","EUR","GBP","JPY","NZD","USD"};  
           
color FG, BG, XG, FGbuttonTF, BGbuttonTF;           
string TF[] = { "1","5","15","30","H1","H4","D","W","M"   } ;
int    CP[] = { PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1, PERIOD_MN1 };
int CCPER,win ;  
string text ;                                                             
//+------------------------------------------------------------------+

bool IsLoaded( string list, string lookfor )
{
   if(StringFind( list , lookfor, 0) ) { return(true) ; } else { return(false) ; } 
}
                                                              
//+------------------------------------------------------------------+
int OnInit()
{
   
   if( TURN_OFF ) { OnDeinit(0); return(0) ; } 
   
   IndicatorShortName("Buttons");
   
   win =    WindowFind("Buttons");  
   
   FG = Tncolor ; 
   BG = Bcolor ;  
   
   FGbuttonTF = Tncolor ; 
   BGbuttonTF = Bcolor ; 
   
   symbol = Symbol() ;
   
   if(StringFind(AccountInfoString(ACCOUNT_COMPANY),"TW",0) >= 0 && StringFind(Symbol(),"i",0) >= 0) { Suffix = "i" ; }  else  
   if(StringFind(AccountInfoString(ACCOUNT_COMPANY),"Gain",0) >= 0) { Suffix = "pro" ; }  
      
 
   int pairlen = StringLen(symbol);
   if(XSize < pairlen*10) { XSize = pairlen*10 -20; }
   
   tSymbols = Symbols;
   
   if(tSymbols == "ALL" ) 
   {
      Symbols = "" ;
      for(int c=0;c<8;c++)
      {
         for(int d=c+1;d<8;d++)
         {
            xySymbol = CurrencyTable[c]+CurrencyTable[d]+Suffix;
            yxSymbol = CurrencyTable[d]+CurrencyTable[c]+Suffix;
            if( MarketInfo(xySymbol,MODE_BID) != 0.0 && IsLoaded( Symbols, xySymbol ) ) { Symbols = Symbols + xySymbol + ";" ; } 
            else if( MarketInfo(yxSymbol,MODE_BID) != 0.0 && IsLoaded( Symbols, yxSymbol ) ) { Symbols = Symbols + yxSymbol + ";" ; }          
         }      
            
      }
   
   }

      int xpos=0,ypos=0,maxx=0,maxy=0;
 
   if(tSymbols != "NONE" )
   {
      
      Symbols=StringTrimLeft(StringTrimRight(Symbols));
      if(StringSubstr(Symbols,StringLen(Symbols)-1,1)!=";")
         Symbols=StringConcatenate(Symbols,";");
   
    
   
      int s=0,i=StringFind(Symbols,";",s);
      string current;
      while(i>0)
        {
         current=StringSubstr(Symbols,s,i-s);
         ArrayResize(aSymbols,ArraySize(aSymbols)+1);
         aSymbols[ArraySize(aSymbols)-1]=current;
         s = i + 1;
         i = StringFind(Symbols,";",s);
        }
   
      ShellsortStringArray(aSymbols, 0, false) ;
    
 //     int xpos=0,ypos=0,maxx=0,maxy=0;
      for(i=0; i0 && MathMod(i,ButtonsInARow)==0) { xpos=0; ypos+=YSize+1; } 
         text = StringSubstr(aSymbols[i],0,StringLen(aSymbols[i])-StringLen(Suffix));
         createButton(UniqueID+":symbol:"+string(i),text,XShift+xpos,YShift+ypos); 
         xpos+=XSize+1; 
      }

/*   
      xpos=0; ypos+=YSize*2;
      for(i=0; i0 && MathMod(i,ButtonsInARow)==0) { xpos=0; ypos+=YSize+1; } createButton(UniqueID+":time:"+string(i),sTfTable[i],XShift+xpos,YShift+ypos); xpos+=XSize+1; }
 */  
    
      setSymbolButtonColor();
      
   }

      xpos=0; ypos+=YSize*2;
      for(int i=0; i0 && MathMod(i,ButtonsInARow)==0) { xpos=0; ypos+=YSize+1; } createButton(UniqueID+":time:"+string(i),sTfTable[i],XShift+xpos,YShift+ypos); xpos+=XSize+1; }
   
      
   setTimeFrameButtonColor();
   
   return(0);
  } 
  

//+------------------------------------------------------------------+
void ShellsortStringArray(string &a[], int size=0, bool desc=false)  {
//+------------------------------------------------------------------+
// Performs a shell sort (rapid resorting) of string array 'a'
//  default is ascending order, unless 'desc' is set to true
  int n=ArraySize(a);
  if (size>0)  n=size;
  int j,i, m;
  string mid;
  for(m=n/2; m>0; m/=2)  {
    for(j=m; j=0; i-=m)  {
        if (desc)   {
          if (a[i+m] <= a[i])
            break;
          else {
            mid = a[i];
            a[i] = a[i+m];
            a[i+m] = mid;
        } }  
        else  {
          if (a[i+m] >= a[i])
            break;
          else {
            mid = a[i];
            a[i] = a[i+m];
            a[i+m] = mid;
        } }  
  } } } 
  return ;
}
  
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  
   switch(reason)
     {
      case REASON_CHARTCHANGE :
      case REASON_RECOMPILE   :
      case REASON_CLOSE       : break;
      default :
        {
         string lookFor       = UniqueID+":";
         int    lookForLength = StringLen(lookFor);
         for(int i=ObjectsTotal()-1; i>=0; i--)
           {
            string objectName=ObjectName(i);  if(StringSubstr(objectName,0,lookForLength)==lookFor) ObjectDelete(objectName);
           }
        }
     }
  }
//+------------------------------------------------------------------+ 
void createButton(string name,string caption,int xpos,int ypos)
  {
   if(ObjectFind(name)!=0)
      ObjectCreate(name,OBJ_BUTTON,win,0,0);
   ObjectSet(name,OBJPROP_CORNER,0);
   ObjectSet(name,OBJPROP_XDISTANCE,xpos);
   ObjectSet(name,OBJPROP_YDISTANCE,ypos);
   ObjectSet(name,OBJPROP_XSIZE,XSize);
   ObjectSet(name,OBJPROP_YSIZE,YSize);
   ObjectSetText(name,caption,FSize,FontType,Tncolor);
   ObjectSet(name,OBJPROP_FONTSIZE,FSize);
   ObjectSet(name,OBJPROP_BORDER_TYPE,BORDER_FLAT);
   ObjectSet(name,OBJPROP_COLOR,FG);
   ObjectSet(name,OBJPROP_BGCOLOR,BG);
   ObjectSet(name,OBJPROP_BACK,Transparent);
   ObjectSet(name,OBJPROP_BORDER_COLOR,Dcolor);
   ObjectSet(name,OBJPROP_STATE,false);
   ObjectSet(name,OBJPROP_HIDDEN,true);
   ObjectSet(name,OBJPROP_CORNER,Corner);
   
  }
//+------------------------------------------------------------------+ 
void setSymbolButtonColor()
  {
   string lookFor       = UniqueID+":symbol:";
   int    lookForLength = StringLen(lookFor);
   for(int i=ObjectsTotal()-1; i>=0; i--)
     {
      FG = Tncolor ; 
      BG = Bcolor ;  
      
      string objectName=ObjectName(i);
      if(StringSubstr(objectName,0,lookForLength)==lookFor)
        {
         string symbol=ObjectGetString(0,objectName,OBJPROP_TEXT)+Suffix;
         
         if(SHOW_CANDLE_COLOR)
         {  
                  if( iClose( symbol, PERIOD_CURRENT, 0 )  >= iOpen( symbol, PERIOD_CURRENT, 0 ) )
                  { BG = colorUp ; } else { BG = colorDn ; }        

                  if(symbol==_Symbol) { XG = FG; FG = BG; BG = XG ; }
                  ObjectSet(objectName,OBJPROP_COLOR,FG);
                  ObjectSet(objectName,OBJPROP_BGCOLOR,BG);                    
         }
         else
         {
            if(symbol!=_Symbol)
               ObjectSet(objectName,OBJPROP_COLOR,Tncolor);
            else  ObjectSet(objectName,OBJPROP_COLOR,Sncolor);
         }
         
         
         
        }
     }
  } 
//+------------------------------------------------------------------+
void setTimeFrameButtonColor()
  {
   string lookFor       = UniqueID+":time:";
   int    lookForLength = StringLen(lookFor);
   
   for(int i=ObjectsTotal()-1; i>=0; i--)
   {
      
      FGbuttonTF = Tncolor ; 
      BGbuttonTF = Bcolor ;  
      
      string objectName=ObjectName(i);
      if(StringSubstr(objectName,0,lookForLength)==lookFor)
        {
         
         string sTime = ObjectGetString(0,objectName,OBJPROP_TEXT) ;
         int time = stringToTimeFrame(sTime);
 
         if(time != _Period)
         {
    
            if(SHOW_CANDLE_COLOR)
            {     
                  if( iClose( symbol, time, 0 )  >= iOpen( symbol, time, 0 ) )
                  { BGbuttonTF = colorUp ; } else { BGbuttonTF = colorDn ; }        
                  ObjectSet(objectName,OBJPROP_COLOR,FGbuttonTF);
                  ObjectSet(objectName,OBJPROP_BGCOLOR,BGbuttonTF);
            }    
            else
            {   
                 ObjectSet(objectName,OBJPROP_COLOR,Tncolor);  
                         
            }
            
          }
          else
          {
            if(SHOW_CANDLE_COLOR)
            {     
                  if( iClose( symbol, time, 0 )  >= iOpen( symbol, time, 0 ) )
                  { BGbuttonTF = colorUp ; } else { BGbuttonTF = colorDn ; }   
                  XG = FGbuttonTF; FGbuttonTF = BGbuttonTF; BGbuttonTF = XG ;            
                  ObjectSet(objectName,OBJPROP_COLOR,FGbuttonTF);
                  ObjectSet(objectName,OBJPROP_BGCOLOR,BGbuttonTF);
            }           
            else { ObjectSet(objectName,OBJPROP_COLOR,Sncolor); } 
          
          }
         
        }
     }
  }


//+------------------------------------------------------------------+ 
string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int    iTfTable[] = {1,5,15,30,60,240,1440,10080,43200}; 
//+------------------------------------------------------------------+
string timeFrameToString(int tf)
  {
   for(int i=ArraySize(iTfTable)-1; i>=0; i--)
      if(tf==iTfTable[i]) return(sTfTable[i]);
   return("");
  } 
//+------------------------------------------------------------------+
int stringToTimeFrame(string tf)
  {
   for(int i=ArraySize(sTfTable)-1; i>=0; i--)
      if(tf==sTfTable[i]) return(iTfTable[i]);
   return(0);
  }
//+------------------------------------------------------------------+
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
  {
   if(id==CHARTEVENT_OBJECT_CLICK && ObjectGet(sparam,OBJPROP_TYPE)==OBJ_BUTTON)
     {   
      if(StringFind(sparam,UniqueID+":symbol:",0)==0) ChartSetSymbolPeriod(0,ObjectGetString(0,sparam,OBJPROP_TEXT)+Suffix,_Period);
      if(StringFind(sparam,UniqueID+":time:"  ,0)==0) ChartSetSymbolPeriod(0,_Symbol,stringToTimeFrame(ObjectGetString(0,sparam,OBJPROP_TEXT)));
      if(StringFind(sparam,UniqueID+":back:"  ,0)==0) ObjectSet(sparam,OBJPROP_STATE,false);
     }
  }
//+------------------------------------------------------------------+
int start() 
{ 
   
   if(SHOW_CANDLE_COLOR)
   {
      setTimeFrameButtonColor() ;
      setSymbolButtonColor() ;
   }
   return(0); 


}
//+------------------------------------------------------------------+
BUOVB_BEOVB 1.mq4 BuySel Alert.mq4

Related Posts

METATRADER4B

BykovTrend_Sig alert.mq4

METATRADER4B

BuySel Alert.mq4

METATRADER4B

BUOVB_BEOVB 1.mq4

METATRADER4B

boSugarman Signals_v3 (1).ex4

METATRADER4B

Bollinger band bars.mq4

METATRADER4B

BO_NRP.mq4

METATRADER4B

BKMGC2.ex4

METATRADER4B

BigReversalSystem_V1.0.ex4

METATRADER4B

Bigger TF Candles WeekDay KB+TT.mq4

METATRADER4B

BetterVolume 1.5 new with Alerts mod.mq4

METATRADER4B

BetterVolume 1.4+Alert.mq4

METATRADER4B

besttrendindicator.ex4

How to use this site.
  1. Subscribe YouTube
  2. Subscribe Facebook
  3. Subscribe Instagram
  4. Download MT4
  5. Watch Youtube Video
  6. Downliad Indicator and Try Trading
  7. Donate to the operator

Recent News

  • xma.mq4
  • YangTrader.ex4
  • zup_v135_all_hl_113.ex4
  • Zone.mq4
  • ZigzagFr_v1.mq4
  • ZigZag_ws_Chanel_SweetSNR.mq4
  • ZigZag_Larsen_out & alerts.mq4
  • Zig Zag Arrow.mq4
  • Zeus.mq4
  • ZeroLag Tema MACD – mtf + lines 2 (1).mq4
  • Zero lag T3.mq4
  • ZB TMA TT.mq4
  • Uni_cross-sep_alerts.mq4
  • Un2.ex4
  • Un.mq4

Donate