_TRO_SAK_MultiPair_v2





//+------------------------------------------------------------------+ 
//|  _TRO_SAK_MultiPair                                              | 
//|                                                                  | 
//|   Copyright © 2007, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFT AND DONATIONS ACCEPTED                                    | 
//|                                                                  |
//|   therumpldone@gmail.com                                         |  
//+------------------------------------------------------------------+ 

//+------------------------------------------------------------------+
//|                                      Easy iCustom and Alerts.mq4 |
//|                                                       Codersguru |
//|                                         http://www.forex-tsd.com |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|                                                  Tickwatcher.mq4 |
//|                                                           mladen |
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 0
#property indicator_minimum 0
#property indicator_maximum 1


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

extern string _            = "pairs and timeframes";
extern string pairs        = "EURUSD";
extern string timeFrames   = "M1;M5;M15;M30;H1;H4;D1;W1;MN";
extern string __           = "levels";

extern bool   ShowLegend   = true;
extern color  ColorPrice   = LimeGreen;
extern color  ColorLabels  = Gray;
//--------iCustom------------------
//
 
extern string Indicator_Name_1="CCI";
//extern int TimeFrame_1=0;
extern int Line_1=0;
extern double Parameter1_1 = 14;
extern double Parameter2_1 = 0;
extern double Parameter3_1 = -100;
extern double Parameter4_1 = -100;
extern double Parameter5_1 = -100;

extern double Ind1_Level3    = 100.00;
extern double Ind1_Level2    = 0.00;
extern double Ind1_Level1    = -100.00;
extern string ___          = "colors";
extern color  Ind1_ColorUp      = ForestGreen;
extern color  Ind1_ColorNeutral = Gray;
extern color  Ind1_ColorDown    = OrangeRed;


extern string ____         = "other";

//--------------------------------
 
extern string Indicator_Name_2="RSI";
extern int TimeFrame_2=0;
extern int Line_2=0;
extern double Parameter1_2 = 2;
extern double Parameter2_2 = 0;
extern double Parameter3_2 = -100;
extern double Parameter4_2 = -100;
extern double Parameter5_2 = -100;
 
extern double Ind2_Level3    = 80.00;
extern double Ind2_Level2    = 50.00;
extern double Ind2_Level1    = 20.00;
 
extern color  Ind2_ColorUp      = ForestGreen;
extern color  Ind2_ColorNeutral = Gray;
extern color  Ind2_ColorDown    = OrangeRed;

 
//--------------------------------
 
extern string Indicator_Name_3="RSI";
extern int TimeFrame_3=0;
extern int Line_3=0;
extern double Parameter1_3 = 3;
extern double Parameter2_3 = 0;
extern double Parameter3_3 = -100;
extern double Parameter4_3 = -100;
extern double Parameter5_3 = -100;

extern double Ind3_Level3    = 80.00;
extern double Ind3_Level2    = 50.00;
extern double Ind3_Level1    = 20.00;
 
extern color  Ind3_ColorUp      = ForestGreen;
extern color  Ind3_ColorNeutral = Gray;
extern color  Ind3_ColorDown    = OrangeRed;

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

int      window;  
int      totalPairs;
int      totalTimeFrames;
int      totalLabels;
int      aTimes[];
string   aPairs[];
string   sTimes[];

//
//
//
//
//

color    Ind3_Color;
color    Ind2_Color;
color    Ind1_Color;
string   Ind3_arrow;
string   Ind2_arrow;
string   Ind1_arrow;
string   labelNames;
string   shortName;
int      corner;


//+-------------iCustom--------------------------------------------+


string Pair_1="", Pair_2="", Pair_3=""  ;    

int TimeFrame_1=0;
                      
//+------------------------------------------------------------------+------------------------------------------------------------------+

int init()
{
   corner     = 0;
   shortName  = MakeUniqueName("TW ","");
   labelNames = shortName;
      IndicatorShortName(shortName);

   //
   //
   //
   //
   //
   
      pairs = StringUpperCase(StringTrimLeft(StringTrimRight(pairs)));
      if (StringSubstr(pairs,StringLen(pairs),1) != ";")
                       pairs = StringConcatenate(pairs,";");
                       

         //
         //
         //
         //
         //                                   

         bool isMini = IsMini();            
         int  s      = 0;
         int  i      = StringFind(pairs,";",s);
         string current;
            while (i > 0)
            {
               current = StringSubstr(pairs,s,i-s);
               if (isMini) current = StringConcatenate(current,"m");
               if (iClose(current,0,0) > 0) {
                     ArrayResize(aPairs,ArraySize(aPairs)+1);
                                 aPairs[ArraySize(aPairs)-1] = current; }
                                 s = i + 1;
                                     i = StringFind(pairs,";",s);
            }

      //
      //
      //
      //
      //

      timeFrames = StringUpperCase(StringTrimLeft(StringTrimRight(timeFrames)));
      if (StringSubstr(timeFrames,StringLen(timeFrames),1) != ";")
                       timeFrames = StringConcatenate(timeFrames,";");

         //
         //
         //
         //
         //                                   
            
         s = 0;
         i = StringFind(timeFrames,";",s);
         int time;
            while (i > 0)
            {
               current = StringSubstr(timeFrames,s,i-s);
               time    = stringToTimeFrame(current);
               if (time > 0) {
                     ArrayResize(sTimes,ArraySize(sTimes)+1);
                     ArrayResize(aTimes,ArraySize(aTimes)+1);
                                 sTimes[ArraySize(sTimes)-1] = TimeFrameToString(time); 
                                 aTimes[ArraySize(aTimes)-1] = time; }
                                 s = i + 1;
                                     i = StringFind(timeFrames,";",s);
            }

      //
      //
      //
      //
      //

      totalTimeFrames = ArraySize(aTimes);
      totalPairs      = ArraySize(aPairs);
      totalLabels     = 0;
   return(0);
}

int deinit()
{
   while (totalLabels>0) { ObjectDelete(StringConcatenate(labelNames,totalLabels)); totalLabels--;}
   return(0);
}


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int start()
{
   int m,n;
   int i,k;

   //
   //
   //
   //
   //

   window      = WindowFind(shortName);
   totalLabels = 0;
         for (i=0,m=80; i < totalPairs;      i++, m+=140)
         for (k=0,n=20; k < totalTimeFrames; k++, n+=13)
               showPair(aPairs[i],aTimes[k],sTimes[k],m,n);
//               showPair(NULL,aTimes[k],sTimes[k],m,n);              
               
   if (ShowLegend) DoShowLegend();
   return(0);
}


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

void DoShowLegend()
{
   corner = 1;
   setObject(next(),"up"       ,30,20,ColorLabels); setObject(next(),"l",11,21,Ind1_ColorUp     ,"Wingdings");
   setObject(next(),"weak up"  ,30,33,ColorLabels); setObject(next(),"¡",10,34,Ind1_ColorUp     ,"Wingdings");
   setObject(next(),"neutral"  ,30,46,ColorLabels); setObject(next(),"¡",10,47,Ind1_ColorNeutral,"Wingdings");
   setObject(next(),"weak down",30,59,ColorLabels); setObject(next(),"¡",10,60,Ind1_ColorDown   ,"Wingdings");
   setObject(next(),"down"     ,30,72,ColorLabels); setObject(next(),"l",11,74,Ind1_ColorDown   ,"Wingdings");
   corner = 0;      
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

void showPair(string pair, int timeFrame, string label, int xdistance, int ydistance)
{
   double price = iClose(pair,0,0);
   
   Pair_1       = pair ;
   TimeFrame_1  = timeFrame ;
   double Ind1_Val   = GetIcustomValue(1,0);
   

   Pair_2       = pair ;
   TimeFrame_2  = timeFrame ;
   double Ind2_Val   = GetIcustomValue(2,0);


   Pair_3       = pair ;
   TimeFrame_3  = timeFrame ;
   double Ind3_Val   = GetIcustomValue(3,0);
   
   
   
//   double adx   = iADX(pair,timeFrame,14,PRICE_CLOSE,0,0);
   
//   double dip   = iRSI(pair,timeFrame,14,PRICE_CLOSE,0);
/*
   double dim   = iADX(pair,timeFrame,14,PRICE_CLOSE,2,0);
   double sarv  = iSAR(pair,timeFrame ,0.02,0.2,0);
   double aosv  = iRSI(pair,timeFrame,14,PRICE_CLOSE,0);
   double aosp  = iRSI(pair,timeFrame,14,PRICE_CLOSE,0);
*/

   //
   //
   //
   //
   //   

      if (ydistance==20) {
            setObject(next(),pair                                           ,xdistance-1 ,20,ColorLabels,"Arial bold",12,270);
            
           setObject(next(), Indicator_Name_1+ " " + Indicator_Name_2+ " " + Indicator_Name_3 ,xdistance+32, 1,ColorPrice ,"Arial bold",12);           



           //setObject(next(),DoubleToStr(price,MarketInfo(pair,MODE_DIGITS)),xdistance-16, 1,ColorPrice ,"Arial bold",12);
         }            
         
      //
      //
      //
      //
      //

      setInd1ColorArrow(Ind1_Val);
      setInd2ColorArrow(Ind2_Val );
      setInd3ColorArrow(Ind3_Val);
      
         setLabel(label,xdistance   ,ydistance,Ind1_Val,Ind1_Color,Ind1_arrow);
         setLabel(" "  ,xdistance+79,ydistance," ",Ind2_Color,Ind2_arrow,false);
         setLabel(" "  ,xdistance+91,ydistance," ",Ind3_Color,Ind3_arrow,false);
}



//+------------------------------------------------------------------+
//| Custom functions and procedures                                  |
//+------------------------------------------------------------------+
string next() { totalLabels++; return(totalLabels); }  
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

void setInd1ColorArrow(double first)
{
 

 
if( first > Ind1_Level3 ) { Ind1_arrow = "l"; Ind1_Color = Ind1_ColorUp; } else {
if( first > Ind1_Level2 ) { Ind1_arrow = "¡"; Ind1_Color = Ind1_ColorUp; } else {
if( first > Ind1_Level1 ) { Ind1_arrow = "¡"; Ind1_Color = Ind1_ColorDown; } else {
                          { Ind1_arrow = "l"; Ind1_Color = Ind1_ColorDown; } } } }
}


void setInd2ColorArrow(double first )
{
if( first > Ind2_Level3 ) { Ind2_arrow = "l"; Ind2_Color = Ind2_ColorUp; } else {
if( first > Ind2_Level2 ) { Ind2_arrow = "¡"; Ind2_Color = Ind2_ColorUp; } else {
if( first > Ind2_Level1 ) { Ind2_arrow = "¡"; Ind2_Color = Ind2_ColorDown; } else {
                          { Ind2_arrow = "l"; Ind2_Color = Ind2_ColorDown; } } } }

}


void setInd3ColorArrow(double first)
{

if( first > Ind3_Level3 ) { Ind3_arrow = "l"; Ind3_Color = Ind3_ColorUp; } else {
if( first > Ind3_Level2 ) { Ind3_arrow = "¡"; Ind3_Color = Ind3_ColorUp; } else {
if( first > Ind3_Level1 ) { Ind3_arrow = "¡"; Ind3_Color = Ind3_ColorDown; } else {
                          { Ind3_arrow = "l"; Ind3_Color = Ind3_ColorDown; } } } }


}  


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

void setLabel(string text,int x,int y,string value, color theColor, string arrow, bool isADX=true)
{
     int last = 0;
     
     if (isADX) {last=67;}
     if (isADX) setObject(next(),text                   ,x     ,y,ColorLabels);
     if (isADX) setObject(next(),StringSubstr(value,0,5),x+30  ,y,theColor);
                setObject(next(),arrow                  ,x+last,y,theColor,"Wingdings",9);
}

//
//
//
//
//

void setObject(string name,string text,int x,int y,color theColor, string font = "Arial",int size=10,int angle=0)
{
   string labelName = StringConcatenate(labelNames,name);

   //
   //
   //
   //
   //
      
      if (ObjectFind(labelName) == -1)
          {
             ObjectCreate(labelName,OBJ_LABEL,window,0,0);
             ObjectSet(labelName,OBJPROP_CORNER,corner);
             if (angle != 0)
                  ObjectSet(labelName,OBJPROP_ANGLE,angle);
          }               
       ObjectSet(labelName,OBJPROP_XDISTANCE,x);
       ObjectSet(labelName,OBJPROP_YDISTANCE,y);
       ObjectSetText(labelName,text,size,font,theColor);
}

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

int stringToTimeFrame(string tfs)
{
   int tf=0;
       tfs = StringTrimLeft(StringTrimRight(StringUpperCase(tfs)));
         if (tfs=="M1" || tfs=="1")     tf=PERIOD_M1;
         if (tfs=="M5" || tfs=="5")     tf=PERIOD_M5;
         if (tfs=="M15"|| tfs=="15")    tf=PERIOD_M15;
         if (tfs=="M30"|| tfs=="30")    tf=PERIOD_M30;
         if (tfs=="H1" || tfs=="60")    tf=PERIOD_H1;
         if (tfs=="H4" || tfs=="240")   tf=PERIOD_H4;
         if (tfs=="D1" || tfs=="1440")  tf=PERIOD_D1;
         if (tfs=="W1" || tfs=="10080") tf=PERIOD_W1;
         if (tfs=="MN" || tfs=="43200") tf=PERIOD_MN1;
  return(tf);
}
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="MN1";
   }
   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);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

string MakeUniqueName(string first, string rest)
{
   string result = first+(MathRand()%1001)+rest;

   while (WindowFind(result)> 0)
          result = first+(MathRand()%1001)+rest;
   return(result);
}
bool IsMini()
{
   if (StringFind(Symbol(),"m") > -1)
         return(true);
   else  return(false);    
}
  

//+-------------iCustom--------------------------------------------+

  
  double GetIcustomValue(int level ,int shift)
  {
      double value =0;
      
      switch(level)
      {
         case 1 :
         {  
            if(Parameter1_1!=-100 && Parameter2_1==-100 && Parameter3_1==-100 && Parameter4_1==-100 && Parameter5_1==-100)
               value = iCustom(Pair_1,TimeFrame_1,Indicator_Name_1,Parameter1_1,Line_1,shift);
            if(Parameter1_1!=-100 && Parameter2_1!=-100 && Parameter3_1==-100 && Parameter4_1==-100 && Parameter5_1==-100)
               value = iCustom(Pair_1,TimeFrame_1,Indicator_Name_1,Parameter1_1,Parameter2_1,Line_1,shift);
            if(Parameter1_1!=-100 && Parameter2_1!=-100 && Parameter3_1!=-100 && Parameter4_1==-100 && Parameter5_1==-100)
               value = iCustom(Pair_1,TimeFrame_1,Indicator_Name_1,Parameter1_1,Parameter2_1,Parameter3_1,Line_1,shift);
            if(Parameter1_1!=-100 && Parameter2_1!=-100 && Parameter3_1!=-100 && Parameter4_1!=-100 && Parameter5_1==-100)
               value = iCustom(Pair_1,TimeFrame_1,Indicator_Name_1,Parameter1_1,Parameter2_1,Parameter3_1,Parameter4_1,Line_1,shift);
            if(Parameter1_1!=-100 && Parameter2_1!=-100 && Parameter3_1!=-100 && Parameter4_1!=-100 && Parameter5_1!=-100)
               value = iCustom(Pair_1,TimeFrame_1,Indicator_Name_1,Parameter1_1,Parameter2_1,Parameter3_1,Parameter4_1,Parameter5_1,Line_1,shift);
            break;
         }
      
         case 2 :
         {  
            if(Parameter1_2!=-100 && Parameter2_2==-100 && Parameter3_2==-100 && Parameter4_2==-100 && Parameter5_2==-100)
               value = iCustom(Pair_2,TimeFrame_2,Indicator_Name_2,Parameter1_2,Line_2,shift);
            if(Parameter1_2!=-100 && Parameter2_2!=-100 && Parameter3_2==-100 && Parameter4_2==-100 && Parameter5_2==-100)
               value = iCustom(Pair_2,TimeFrame_2,Indicator_Name_2,Parameter1_2,Parameter2_2,Line_2,shift);
            if(Parameter1_2!=-100 && Parameter2_2!=-100 && Parameter3_2!=-100 && Parameter4_2==-100 && Parameter5_2==-100)
               value = iCustom(Pair_2,TimeFrame_2,Indicator_Name_2,Parameter1_2,Parameter2_2,Parameter3_2,Line_2,shift);
            if(Parameter1_2!=-100 && Parameter2_2!=-100 && Parameter3_2!=-100 && Parameter4_2!=-100 && Parameter5_2==-100)
               value = iCustom(Pair_2,TimeFrame_2,Indicator_Name_2,Parameter1_2,Parameter2_2,Parameter3_2,Parameter4_2,Line_2,shift);
            if(Parameter1_2!=-100 && Parameter2_2!=-100 && Parameter3_2!=-100 && Parameter4_2!=-100 && Parameter5_2!=-100)
               value = iCustom(Pair_2,TimeFrame_2,Indicator_Name_2,Parameter1_2,Parameter2_2,Parameter3_2,Parameter4_2,Parameter5_2,Line_2,shift);
            break;
         }
      
         case 3 :
         {  
            if(Parameter1_3!=-100 && Parameter2_3==-100 && Parameter3_3==-100 && Parameter4_3==-100 && Parameter5_3==-100)
               value = iCustom(Pair_3,TimeFrame_3,Indicator_Name_3,Parameter1_3,Line_3,shift);
            if(Parameter1_3!=-100 && Parameter2_3!=-100 && Parameter3_3==-100 && Parameter4_3==-100 && Parameter5_3==-100)
               value = iCustom(Pair_3,TimeFrame_3,Indicator_Name_3,Parameter1_3,Parameter2_3,Line_3,shift);
            if(Parameter1_3!=-100 && Parameter2_3!=-100 && Parameter3_3!=-100 && Parameter4_3==-100 && Parameter5_3==-100)
               value = iCustom(Pair_3,TimeFrame_3,Indicator_Name_3,Parameter1_3,Parameter2_3,Parameter3_3,Line_3,shift);
            if(Parameter1_3!=-100 && Parameter2_3!=-100 && Parameter3_3!=-100 && Parameter4_3!=-100 && Parameter5_3==-100)
               value = iCustom(Pair_3,TimeFrame_3,Indicator_Name_3,Parameter1_3,Parameter2_3,Parameter3_3,Parameter4_3,Line_3,shift);
            if(Parameter1_3!=-100 && Parameter2_3!=-100 && Parameter3_3!=-100 && Parameter4_3!=-100 && Parameter5_3!=-100)
               value = iCustom(Pair_3,TimeFrame_3,Indicator_Name_3,Parameter1_3,Parameter2_3,Parameter3_3,Parameter4_3,Parameter5_3,Line_3,shift);
            break;
         }
      }
       
      return (value);

  }
  



Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar


Indicator Curves created:


Indicators Used:

Movement directional index
Parabolic Stop and Reverse system
Relative strength index



Custom Indicators Used:
Indicator_Name_1
Indicator_Name_2
Indicator_Name_3

Order Management characteristics:

Other Features: