MTF_MACD_sBar_4Cm





//+------------------------------------------------------------------+
//|   mod of cja mtf 4c macd /   macd Sidebar       MTF_MACD_Bar.mq4 |
//|       forex-tsd.com  Copyright © 2006, MetaQuotes Software Corp. |
//|                                     http://www.metaquotes.net ik |  
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
//+------------------------------------------------------------------+
//|                                                    FlatTrend.mq4 |
//|                                                       Kirk Sloan |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Kirk Sloan"
#property link      "http://www.metaquotes.net"
#property link      "Modified by cja"

#property indicator_separate_window

#property indicator_buffers 4
#property indicator_color1 Green
#property indicator_color2 YellowGreen
#property indicator_color3 Crimson
#property indicator_color4 Tomato
#property indicator_maximum 77
#property indicator_minimum 1

//---- input parameters
extern int Minutes=0;
extern int MACD_Fast = 8;     // 5  |12 Standart | 8 CJA Settings | 5 Valeo  
extern int MACD_Slow = 17;    // 35 |26          | 17             | 8
extern int MACD_MA = 9;       // 5  |9           | 9              | 5
extern int MACDbarLevel = 2;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];


/*double Ma;
double hhigh, llow;
double Psar;
double MA1,MA2,MA3;
double PADX,NADX;*/
string TimeFrameStr;

double MACD_Signal;
double MACD_Main;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
  SetIndexStyle(0,DRAW_ARROW);
  SetIndexBuffer(0,ExtMapBuffer1);
  SetIndexStyle(1,DRAW_ARROW);
  SetIndexBuffer(1,ExtMapBuffer2);
  SetIndexStyle(2,DRAW_ARROW);
  SetIndexBuffer(2,ExtMapBuffer3);
  SetIndexStyle(3,DRAW_ARROW);
  SetIndexBuffer(3,ExtMapBuffer4);

   SetIndexArrow(0,59);
   SetIndexArrow(1,59);
   SetIndexArrow(2,59);
   SetIndexArrow(3,59);


   SetIndexLabel(0,"MACD>0Up["+Minutes+"]("+MACD_Fast+";"+MACD_Slow+";"+MACD_MA+")");
   SetIndexLabel(1,"MACD>0Dn["+Minutes+"]("+MACD_Fast+";"+MACD_Slow+";"+MACD_MA+")");
   SetIndexLabel(2,"MACD<0Dn["+Minutes+"]("+MACD_Fast+";"+MACD_Slow+";"+MACD_MA+")");
   SetIndexLabel(3,"MACD<0Up["+Minutes+"]("+MACD_Fast+";"+MACD_Slow+";"+MACD_MA+")");


switch(Minutes)
   {
      case 1 : TimeFrameStr="Period_M1"; break;
      case 5 : TimeFrameStr="Period_M5"; break;
      case 15 : TimeFrameStr="Period_M15"; break;
      case 30 : TimeFrameStr="Period_M30"; break;
      case 60 : TimeFrameStr="Period_H1"; break;
      case 240 : TimeFrameStr="Period_H4"; break;
      case 1440 : TimeFrameStr="Period_D1"; break;
      case 10080 : TimeFrameStr="Period_W1"; break;
      case 43200 : TimeFrameStr="Period_MN1"; break;
      default : TimeFrameStr="Current Timeframe"; Minutes=0;
   }
   IndicatorShortName("MTF_MACDsb("+TimeFrameStr+")["+MACD_Fast+";"+MACD_Slow+";"+MACD_MA+";");  

 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   datetime TimeArray[];
   int    i,limit,y=0,counted_bars=IndicatorCounted();
 
// Plot defined time frame on to current time frame
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),Minutes); 
   
   limit=Bars-counted_bars+Minutes/Period();
   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++;//for (int i = 0; i < 300; i++){
 
  ExtMapBuffer1[i]=EMPTY_VALUE;
   ExtMapBuffer2[i]=EMPTY_VALUE;
   ExtMapBuffer3[i]=EMPTY_VALUE;
   ExtMapBuffer4[i]=EMPTY_VALUE;
   

  MACD_Signal=iMACD(NULL,Minutes,MACD_Fast,MACD_Slow,MACD_MA,0,1,y);
  MACD_Main  =iMACD(NULL,Minutes,MACD_Fast,MACD_Slow,MACD_MA,0,0,y);
   
   if(MACD_Signal >  MACD_Main && MACD_Main > 0)ExtMapBuffer1[i] = MACDbarLevel;//Sig above MACD & Above 0
   if(MACD_Signal <= MACD_Main && MACD_Main > 0)ExtMapBuffer2[i] = MACDbarLevel;//Sig Below=MACD & Above 0

   if(MACD_Signal > MACD_Main && MACD_Main <  0)ExtMapBuffer3[i] = MACDbarLevel;//Sig above MACD & Below 0
  /* if(ExtMapBuffer1[i] == 0 && ExtMapBuffer2[i] == 0)
   {ExtMapBuffer3[i] = 1;}*/
   if(MACD_Signal <= MACD_Main && MACD_Main <=0)ExtMapBuffer4[i] = MACDbarLevel;//Sig Below=MACD & Below =0
  
}
 

   //----  Refresh buffers ++++++++++++++++++++ upgrade by Raff  
     int TimeFrame;   if (TimeFrame>Period()) {
     int PerINT=TimeFrame/Period()+1;
     datetime TimeArr[]; ArrayResize(TimeArr,PerINT);
     ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period()); 
     for(i=0;i<PerINT+1;i++) {if (TimeArr[i]>=TimeArray[0]) {
//----
 /********************************************************  
    Refresh buffers:         buffer[i] = buffer[0];
 ********************************************************/  

      ExtMapBuffer1[i] = ExtMapBuffer1[0];
      ExtMapBuffer2[i] = ExtMapBuffer2[0];
      ExtMapBuffer3[i] = ExtMapBuffer3[0];
      ExtMapBuffer4[i] = ExtMapBuffer4[0];

//----
   } } }
//+++++++++++++++++++++++++++++++++++++++++++++++  Raff  

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



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:

Implements a curve of type DRAW_ARROW


Indicators Used:

MACD Histogram


Custom Indicators Used:

Order Management characteristics:

Other Features: