//+------------------------------------------------------------------+
//|                                  Symphonie Extreme Indicator.mq4 |
//|  Based on Cycle Identifier                                       |
//+------------------------------------------------------------------+

/*
Modified by Zen to add alert when top or bottom is detected on previous candle.
add alert option for buy or sell or both options by mtuppers

Modified by Mediator for MTF functionality
*/
#property copyright "Copyright © 2006, Mediator"
#property link      "charttechnology@online.de"

#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Black

#property indicator_color2 Blue     //major bottom
#property indicator_color3 Red      //major top
#property indicator_color4 Black    //minor bottom
#property indicator_color5 Black    //minor top

#property indicator_color6 Black

#property indicator_width1 0
#property indicator_width2 4
#property indicator_width3 4
#property indicator_width4 0
#property indicator_width5 0
#property indicator_width6 0

#property indicator_minimum -1.2
#property indicator_maximum 1.2

extern int TimeFrame=60;
extern int       PriceActionFilter=1;
extern int       Length=3;
extern int       MajorCycleStrength=4;
extern bool      UseCycleFilter=false;
extern int       UseFilterSMAorRSI=1;
extern int       FilterStrengthSMA=12;
extern int       FilterStrengthRSI=21;
extern bool      SoundAlert = true;
extern bool      WaitForClose = true;
extern string    note1 = "alert all = 0",
                 note2 = "buy only = 1, sell only = 2";
extern int       alertsOption = 0;

//---- input parameters
/*************************************************************************
PERIOD_M1   1
PERIOD_M5   5
PERIOD_M15  15
PERIOD_M30  30 
PERIOD_H1   60
PERIOD_H4   240
PERIOD_D1   1440
PERIOD_W1   10080
PERIOD_MN1  43200
You must use the numeric value of the timeframe that you want to use
when you set the TimeFrame' value with the indicator inputs.
---------------------------------------
PRICE_CLOSE    0 Close price. 
PRICE_OPEN     1 Open price. 
PRICE_HIGH     2 High price. 
PRICE_LOW      3 Low price. 
PRICE_MEDIAN   4 Median price, (high+low)/2. 
PRICE_TYPICAL  5 Typical price, (high+low+close)/3. 
PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4. 
You must use the numeric value of the Applied Price that you want to use
when you set the 'applied_price' value with the indicator inputs.
---------------------------------------
MODE_SMA    0 Simple moving average, 
MODE_EMA    1 Exponential moving average, 
MODE_SMMA   2 Smoothed moving average, 
MODE_LWMA   3 Linear weighted moving average. 
You must use the numeric value of the MA Method that you want to use
when you set the 'ma_method' value with the indicator inputs.

**************************************************************************/


double LineBuffer[];
double MajorCycleBuy[];
double MajorCycleSell[];
double MinorCycleBuy[];
double MinorCycleSell[];
double ZL1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(0,LineBuffer);
   
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexBuffer(1,MajorCycleBuy);
   
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexBuffer(2,MajorCycleSell);
   
   SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,1);
   SetIndexBuffer(3,MinorCycleBuy);
   
   SetIndexStyle(4,DRAW_HISTOGRAM,STYLE_SOLID,1);
   SetIndexBuffer(4,MinorCycleSell);
   
   SetIndexStyle(5,DRAW_NONE);
   SetIndexBuffer(5,ZL1);
   
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(2,0.0);
   SetIndexEmptyValue(3,0.0);
   SetIndexEmptyValue(4,0.0);
   SetIndexEmptyValue(5,0.0);  
   Sleep(500);
   switch(TimeFrame)
   {
      case 1 : string 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";
   } 
   IndicatorShortName(TimeFrameStr);  
  }
//----
   return(0);
 
//+------------------------------------------------------------------+
//| MTF Moving Average                                   |
//+------------------------------------------------------------------+
int start()
  {
   datetime TimeArray[];
   int    i,shift,limit,y=0,counted_bars=IndicatorCounted();
    
// Plot defined timeframe on to current timeframe   
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 
   
   limit=Bars-counted_bars+TimeFrame/Period();
   //limit=Bars-counted_bars;  bad
   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++; 
   
 /***********************************************************   
   Add your main indicator loop below.  You can reference an existing
      indicator with its iName  or iCustom.
   Rule 1:  Add extern inputs above for all neccesary values   
   Rule 2:  Use 'TimeFrame' for the indicator timeframe
   Rule 3:  Use 'y' for the indicator's shift value
 **********************************************************/  
    
   LineBuffer[i]=iCustom(Symbol(),TimeFrame,"Symphonie_Extreme_Cycle_Indikator",PriceActionFilter,Length,
   MajorCycleStrength,UseCycleFilter,UseFilterSMAorRSI,FilterStrengthSMA,FilterStrengthRSI,SoundAlert,
   WaitForClose,note1,note2,alertsOption,0,y) ; 
   
   MajorCycleBuy[i] = iCustom(Symbol(),TimeFrame,"Symphonie_Extreme_Cycle_Indikator",PriceActionFilter,Length,
   MajorCycleStrength,UseCycleFilter,UseFilterSMAorRSI,FilterStrengthSMA,FilterStrengthRSI,SoundAlert,
   WaitForClose,note1,note2,alertsOption,1,y) ; 
   
    MajorCycleSell[i]= iCustom(Symbol(),TimeFrame,"Symphonie_Extreme_Cycle_Indikator",PriceActionFilter,Length,
   MajorCycleStrength,UseCycleFilter,UseFilterSMAorRSI,FilterStrengthSMA,FilterStrengthRSI,SoundAlert,
   WaitForClose,note1,note2,alertsOption,2,y) ; 
   
   MinorCycleBuy[i]= iCustom(Symbol(),TimeFrame,"Symphonie_Extreme_Cycle_Indikator",PriceActionFilter,Length,
   MajorCycleStrength,UseCycleFilter,UseFilterSMAorRSI,FilterStrengthSMA,FilterStrengthRSI,SoundAlert,
   WaitForClose,note1,note2,alertsOption,3,y) ; 
   
   MinorCycleSell[i]= iCustom(Symbol(),TimeFrame,"Symphonie_Extreme_Cycle_Indikator",PriceActionFilter,Length,
   MajorCycleStrength,UseCycleFilter,UseFilterSMAorRSI,FilterStrengthSMA,FilterStrengthRSI,SoundAlert,
   WaitForClose,note1,note2,alertsOption,4,y) ; 
   
   ZL1[i]= iCustom(Symbol(),TimeFrame,"Symphonie_Extreme_Cycle_Indikator",PriceActionFilter,Length,
   MajorCycleStrength,UseCycleFilter,UseFilterSMAorRSI,FilterStrengthSMA,FilterStrengthRSI,SoundAlert,
   WaitForClose,note1,note2,alertsOption,5,y) ; 
   }  
     
//
   
  
  
   return(0);
  }
//+------------------------------------------------------------------+