//+------------------------------------------------------------------+
//|                                                CustmCharting.mq5 |
//|                                        Copyright 2012, AZ-iNVEST |
//|                                          http://www.az-invest.eu |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011-2016, AZ-iNVEST"
#property link      "http://www.az-invest.eu"
#property version   "1.41"
#property icon "icons//customCharting.ico"
#property description "Median renko, Turbo renko, Renko && PointO chart configurations."
#property description "All in a single, robust indicator for Metatrader 5."
#property indicator_chart_window

#define candle_type "MedianRenko"

#property indicator_buffers 14
#property indicator_plots   8
//--- plot Bars

#property indicator_label1  "MA1";
#property indicator_type1 DRAW_LINE
#property indicator_color1  clrGold
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1

#property indicator_label2  "MA2";
#property indicator_type2 DRAW_LINE
#property indicator_color2  clrDodgerBlue
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1

#property indicator_label3  "Donchian High";
#property indicator_type3 DRAW_LINE
#property indicator_color3  clrSilver
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1

#property indicator_label4  "Donchian Mid";
#property indicator_type4 DRAW_LINE
#property indicator_color4  clrSilver
#property indicator_style4  STYLE_DOT
#property indicator_width4  1

#property indicator_label5  "Donchian Low";
#property indicator_type5 DRAW_LINE
#property indicator_color5  clrSilver
#property indicator_style5 STYLE_SOLID
#property indicator_width5  1


#property indicator_label6  candle_type+" OLHC";
#property indicator_type6  DRAW_COLOR_CANDLES
#property indicator_color6  clrFireBrick,clrGreen,clrRed,clrLime
#property indicator_style6  STYLE_SOLID
#property indicator_width6  1

#property indicator_type11 DRAW_NONE
#property indicator_label11  "Tick volume";
#property indicator_type12 DRAW_NONE
#property indicator_label12  "Bar's open time";


enum BufferDataType
{
   Close = 0,
   Open = 1,
   High = 2,
   Low = 3,
   Median_Price = 4,
   Typical_Price = 5,
   Weighted_Close = 6,
};
 
enum MaMethodType
{
   Simple = 0,
   Exponential = 1,
   Smoothed = 2,
   LinearWeighted = 3,
};
 
//--- Indicator buffers
double         CustomBuffer1[];
double         CustomBuffer2[];

double         CandleOpen[];
double         CandleHigh[];
double         CandleLow[];
double         CandleClose[];
double         CandleColor[];
double         TickVolume[];
double         CandleOpenTime[];
double         MA1[];
double         MA2[];
double         DonchianHigh[];
double         DonchianMid[];
double         DonchianLow[];

int            MA1weightSum = 0;
int            MA2weightSum = 0;

input int barSizeInTicks = 100; // Bars size (in ticks)
      double customBarSize = barSizeInTicks * Point();
input double _retracementFactor = 0.5; // Retracement factor (0.01 to 1.00)
      double retracementFactor = 0.5;
input bool   symetricalReversals = true; // Symmetrical reversals
input bool   showWicks = true; // Show wicks
input datetime startFromDateTime = 0; // Start building chart from date/time
input bool  resetOpenOnNewTradingDay = false; // Synchronize first bar's open on new day
input bool  showNextBarLevels = true; // Show current bar's close projections
input color HighThresholdIndicatorColor = clrLime; // Bullish bar projection color
input color LowThresholdIndicatorColor = clrRed; // Bearish bar projection color
input bool  showCurrentBarOpenTime = true; // Display current bar's open time
input color InfoTextColor = clrWhite; // Current bar's open time info color
input bool      UseSoundSignalOnNewBar = false; // Play sound on new bar
input bool      OnlySignalReversalBars = false; // Only play sound on reversals
input bool      UseAlertWindow = false; // Display Alert window with new bar info
input string    SoundFileBull = "news.wav"; // Use sound file for bullish bar close
input string    SoundFileBear = "news.wav"; // Use sound file for bearish bar close
input bool MA1on = false; // Show first MA 
input int MA1period = 20; // 1st MA period
input MaMethodType MA1method = Exponential; // 1st MA metod
input BufferDataType MA1applyTo = Close; //1st MA apply to
input bool MA2on = false; // Show second MA 
input int MA2period = 50; // 2nd MA period
input MaMethodType MA2method = Exponential; // 2nd MA method
input BufferDataType MA2applyTo = Close; // 2nd MA apply to
input bool DonchianOn = false; // Show Donchian Channel
input int DonchianPeriod = 20; // Period of averaging


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{   
   return(INIT_SUCCEEDED);
}
  
void OnDeinit(const int reason)
{

}
  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate (const int rates_total,      // size of input time series
                 const int prev_calculated,  // bars handled in previous call
                 const datetime& time[],     // Time
                 const double& open[],       // Open
                 const double& high[],       // High
                 const double& low[],        // Low
                 const double& close[],      // Close
                 const long& tick_volume[],  // Tick Volume
                 const long& volume[],       // Real Volume
                 const int& spread[]         // Spread
   )
  {  
   return(rates_total);
  }
//+------------------------------------------------------------------+
