Complex_Common_Frames





//+------------------------------------------------------------------+
//|                                           Copmlex_Common_New.mq4 |
//|                                              SemSemFX@rambler.ru |
//|              http://onix-trade.net/forum/index.php?showtopic=107 |
//+------------------------------------------------------------------+
#property copyright "SemSemFX@rambler.ru"
#property link      "http://onix-trade.net/forum/index.php?showtopic=107"

#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Green
#property indicator_color2 DarkBlue
#property indicator_color3 Red
#property indicator_color4 Black
#property indicator_color5 Maroon
#property indicator_color6 DarkSlateGray
#property indicator_color7 Purple
#property indicator_color8 Teal
//---- buffers
double USD[];
double EUR[];
double GBP[];
double CHF[];
double JPY[];
double AUD[];
double CAD[];
double NZD[];
//---- parameters
// for monthly
extern int mn_per = 5;//12
extern int mn_fast = 3;
// for weekly
extern int w_per = 5;//9
extern int w_fast = 3;
// for daily
extern int d_per = 5;
extern int d_fast = 3;
// for H4
extern int h4_per = 5;//18
extern int h4_fast = 3;//6
// for H1
extern int h1_per = 5;//24
extern int h1_fast = 3;//8
// for M30
extern int m30_per = 5;//16
extern int m30_fast = 3;//2
// for M15
extern int m15_per = 5;//16
extern int m15_fast = 3;//4
// for M5
extern int m5_per = 5;//12
extern int m5_fast = 3;
// for M1
extern int m1_per = 5;//30
extern int m1_fast = 3;//10

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorShortName("USD:Green;EUR:Blue;GBP:Red;CHF:Black;JPY:Maroon;AUD:Gray;CAD:Purple;NZD:Teal");
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,USD);
   SetIndexLabel(0, "USD"); 
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,EUR);
   SetIndexLabel(1, "EUR"); 
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,GBP);
   SetIndexLabel(2, "GBP"); 
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,CHF);
   SetIndexLabel(3, "CHF"); 
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,JPY);
   SetIndexLabel(4, "JPY"); 
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(5,AUD);
   SetIndexLabel(5, "AUD"); 
   SetIndexStyle(6,DRAW_LINE);
   SetIndexBuffer(6,CAD);
   SetIndexLabel(6, "CAD"); 
   SetIndexStyle(7,DRAW_LINE);
   SetIndexBuffer(7,NZD);
   SetIndexLabel(7, "NZD"); 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
     int limit;
     int counted_bars=IndicatorCounted();
  //---- ïðîâåðêà íà âîçìîæíûå îøèáêè
     if(counted_bars<0) return(-1);
  //---- ïîñëåäíèé ïîñ÷èòàííûé áàð áóäåò ïåðåñ÷èòàí
     if(counted_bars>0) counted_bars-=10;
     limit=Bars-counted_bars;
  //---- îñíîâíîé öèêë
      int Price=6;
      int Mode=MODE_LWMA;
      int per1,per2;
      switch(Period())
        {
         case 1:     per1 = m1_per; per2 = m1_fast; break;
         case 5:     per1 = m5_per; per2 = m5_fast; break;
         case 15:    per1 = m15_per;per2 = m15_fast; break;
         case 30:    per1 = m30_per;per2 = m30_fast; break;
         case 60:    per1 = h1_per; per2 = h1_fast; break;
         case 240:   per1 = h4_per; per2 = h4_fast; break;
         case 1440:  per1 = d_per;  per2 = d_fast; break;
         case 10080: per1 = w_per;  per2 = w_fast; break;
         case 43200: per1 = mn_per; per2 = mn_fast; break;
        }
     for(int i=0; i<limit; i++)
       {
        USD[i]=
            (ma("EURUSD",per1,Mode,Price,i)-
            ma("EURUSD",per2,Mode,Price,i))*10000
            +
            (ma("GBPUSD",per1,Mode,Price,i)-
            ma("GBPUSD",per2,Mode,Price,i))*10000
            +
            (ma("USDCHF",per2,Mode,Price,i)-
            ma("USDCHF",per1,Mode,Price,i))*10000
            +
            (ma("USDJPY",per2,Mode,Price,i)-
            ma("USDJPY",per1,Mode,Price,i))*100
            +
            (ma("AUDUSD",per1,Mode,Price,i)-
            ma("AUDUSD",per2,Mode,Price,i))*10000
            +
            (ma("USDCAD",per2,Mode,Price,i)-
            ma("USDCAD",per1,Mode,Price,i))*10000
            +
            (ma("NZDUSD",per1,Mode,Price,i)-
            ma("NZDUSD",per2,Mode,Price,i))*10000
            ;
        EUR[i]=
            (ma("EURUSD",per2,Mode,Price,i)-
            ma("EURUSD",per1,Mode,Price,i))*10000
            +
            (ma("EURGBP",per2,Mode,Price,i)-
            ma("EURGBP",per1,Mode,Price,i))*10000
            +
            (ma("EURCHF",per2,Mode,Price,i)-
            ma("EURCHF",per1,Mode,Price,i))*10000
            +
            (ma("EURJPY",per2,Mode,Price,i)-
            ma("EURJPY",per1,Mode,Price,i))*100
            +
            (ma("EURAUD",per2,Mode,Price,i)-
            ma("EURAUD",per1,Mode,Price,i))*10000
            +
            (ma("EURCAD",per2,Mode,Price,i)-
            ma("EURCAD",per1,Mode,Price,i))*10000
            +
            (ma("EURNZD",per2,Mode,Price,i)-
            ma("EURNZD",per1,Mode,Price,i))*10000
            ;
        GBP[i]=
            (ma("GBPUSD",per2,Mode,Price,i)-
            ma("GBPUSD",per1,Mode,Price,i))*10000
            +
            (ma("EURGBP",per1,Mode,Price,i)-
            ma("EURGBP",per2,Mode,Price,i))*10000
            +
            (ma("GBPCHF",per2,Mode,Price,i)-
            ma("GBPCHF",per1,Mode,Price,i))*10000
            +
            (ma("GBPJPY",per2,Mode,Price,i)-
            ma("GBPJPY",per1,Mode,Price,i))*100
            +
            (ma("GBPAUD",per2,Mode,Price,i)-
            ma("GBPAUD",per1,Mode,Price,i))*10000
            +
            (ma("GBPCAD",per2,Mode,Price,i)-
            ma("GBPCAD",per1,Mode,Price,i))*10000
            +
            (ma("GBPNZD",per2,Mode,Price,i)-
            ma("GBPNZD",per1,Mode,Price,i))*10000
            ;
        CHF[i]=
            (ma("USDCHF",per1,Mode,Price,i)-
            ma("USDCHF",per2,Mode,Price,i))*10000
            +
            (ma("EURCHF",per1,Mode,Price,i)-
            ma("EURCHF",per2,Mode,Price,i))*10000
            +
            (ma("GBPCHF",per1,Mode,Price,i)-
            ma("GBPCHF",per2,Mode,Price,i))*10000
            +
            (ma("CHFJPY",per2,Mode,Price,i)-
            ma("CHFJPY",per1,Mode,Price,i))*100
            +
            (ma("AUDCHF",per1,Mode,Price,i)-
            ma("AUDCHF",per2,Mode,Price,i))*10000
            +
            (ma("CADCHF",per1,Mode,Price,i)-
            ma("CADCHF",per2,Mode,Price,i))*10000
            +
            (ma("NZDCHF",per1,Mode,Price,i)-
            ma("NZDCHF",per2,Mode,Price,i))*10000
            ;
        JPY[i]=
            (ma("USDJPY",per1,Mode,Price,i)-
            ma("USDJPY",per2,Mode,Price,i))*100
            +
            (ma("EURJPY",per1,Mode,Price,i)-
            ma("EURJPY",per2,Mode,Price,i))*100
            +
            (ma("GBPJPY",per1,Mode,Price,i)-
            ma("GBPJPY",per2,Mode,Price,i))*100
            +
            (ma("CHFJPY",per1,Mode,Price,i)-
            ma("CHFJPY",per2,Mode,Price,i))*100
            +
            (ma("AUDJPY",per1,Mode,Price,i)-
            ma("AUDJPY",per2,Mode,Price,i))*100
            +
            (ma("CADJPY",per1,Mode,Price,i)-
            ma("CADJPY",per2,Mode,Price,i))*100
            +
            (ma("NZDJPY",per1,Mode,Price,i)-
            ma("NZDJPY",per2,Mode,Price,i))*100
            ;
        AUD[i]=
            (ma("AUDUSD",per2,Mode,Price,i)-
            ma("AUDUSD",per1,Mode,Price,i))*10000
            +
            (ma("EURAUD",per1,Mode,Price,i)-
            ma("EURAUD",per2,Mode,Price,i))*10000
            +
            (ma("GBPAUD",per1,Mode,Price,i)-
            ma("GBPAUD",per2,Mode,Price,i))*10000
            +
            (ma("AUDJPY",per2,Mode,Price,i)-
            ma("AUDJPY",per1,Mode,Price,i))*100
            +
            (ma("AUDCHF",per2,Mode,Price,i)-
            ma("AUDCHF",per1,Mode,Price,i))*10000
            +
            (ma("AUDCAD",per2,Mode,Price,i)-
            ma("AUDCAD",per1,Mode,Price,i))*10000
            +
            (ma("AUDNZD",per2,Mode,Price,i)-
            ma("AUDNZD",per1,Mode,Price,i))*10000
            ;
        CAD[i]=
            (ma("USDCAD",per1,Mode,Price,i)-
            ma("USDCAD",per2,Mode,Price,i))*10000
            +
            (ma("EURCAD",per1,Mode,Price,i)-
            ma("EURCAD",per2,Mode,Price,i))*10000
            +
            (ma("GBPCAD",per1,Mode,Price,i)-
            ma("GBPCAD",per2,Mode,Price,i))*10000
            +
            (ma("AUDCAD",per1,Mode,Price,i)-
            ma("AUDCAD",per2,Mode,Price,i))*10000
            +
            (ma("CADCHF",per2,Mode,Price,i)-
            ma("CADCHF",per1,Mode,Price,i))*10000
            +
            (ma("CADJPY",per2,Mode,Price,i)-
            ma("CADJPY",per1,Mode,Price,i))*100
            +
            (ma("NZDCAD",per1,Mode,Price,i)-
            ma("NZDCAD",per2,Mode,Price,i))*10000
            ;
        NZD[i]=
            (ma("NZDUSD",per2,Mode,Price,i)-
            ma("NZDUSD",per1,Mode,Price,i))*10000
            +
            (ma("EURNZD",per1,Mode,Price,i)-
            ma("EURNZD",per2,Mode,Price,i))*10000
            +
            (ma("GBPNZD",per1,Mode,Price,i)-
            ma("GBPNZD",per2,Mode,Price,i))*10000
            +
            (ma("NZDJPY",per2,Mode,Price,i)-
            ma("NZDJPY",per1,Mode,Price,i))*100
            +
            (ma("NZDCHF",per2,Mode,Price,i)-
            ma("NZDCHF",per1,Mode,Price,i))*10000
            +
            (ma("NZDCAD",per2,Mode,Price,i)-
            ma("NZDCAD",per1,Mode,Price,i))*10000
            +
            (ma("AUDNZD",per1,Mode,Price,i)-
            ma("AUDNZD",per1,Mode,Price,i))*10000
            ;
       }
  //----
    return(0);
  }
//+------------------------------------------------------------------+

double ma(string sym, int per, int Mode, int Price, int i){
double res=0;
int k=1;
int ma_shift=0;
int tf=0;
      switch(Period())
        {
         case 1:     res+=iMA(sym, tf, per*k, ma_shift, Mode, Price,i); k+=5;
         case 5:     res+=iMA(sym, tf, per*k, ma_shift, Mode, Price,i); k+=3;
         case 15:    res+=iMA(sym, tf, per*k, ma_shift, Mode, Price,i); k+=2;
         case 30:    res+=iMA(sym, tf, per*k, ma_shift, Mode, Price,i); k+=2;
         case 60:    res+=iMA(sym, tf, per*k, ma_shift, Mode, Price,i); k+=4;
         case 240:   res+=iMA(sym, tf, per*k, ma_shift, Mode, Price,i); k+=6;
         case 1440:  res+=iMA(sym, tf, per*k, ma_shift, Mode, Price,i); k+=4;
         case 10080: res+=iMA(sym, tf, per*k, ma_shift, Mode, Price,i); k+=4;
         case 43200: res+=iMA(sym, tf, per*k, ma_shift, Mode, Price,i); 
        }
   return(res);
}   






Sample





Analysis



Market Information Used:



Indicator Curves created:

Implements a curve of type DRAW_LINE


Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: