//+------------------------------------------------------------------+ //| cascade_trend.mq5 | //| cascade_trend Copyright 2016, fxborg | //| http://fxborg-labo.hateblo.jp/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2016, fxborg" #property link "http://fxborg-labo.hateblo.jp/" #property version "1.00" #property indicator_buffers 15 #property indicator_plots 1 #property indicator_levelcolor Silver #property indicator_minimum 0 #property indicator_maximum 1 #property indicator_separate_window #property indicator_type1 DRAW_COLOR_HISTOGRAM #property indicator_color1 clrDarkGreen,clrLimeGreen,clrYellow,clrOrangeRed,clrMaroon #property indicator_width1 6 #property indicator_type2 DRAW_COLOR_LINE #property indicator_color2 clrAqua,clrDeepPink #property indicator_width2 2 #property indicator_type3 DRAW_COLOR_LINE #property indicator_color3 clrAqua,clrDeepPink #property indicator_width3 2 #property indicator_type4 DRAW_COLOR_LINE #property indicator_color4 clrAqua,clrDeepPink #property indicator_width4 2 #property indicator_type5 DRAW_COLOR_LINE #property indicator_color5 clrAqua,clrDeepPink #property indicator_width5 2 #property indicator_type6 DRAW_COLOR_LINE #property indicator_color6 clrAqua,clrDeepPink #property indicator_width6 2 #property indicator_type7 DRAW_COLOR_LINE #property indicator_color7 clrAqua,clrDeepPink #property indicator_width7 2 //+------------------------------------------------------------------+ //--- input parameters input double InpSize =0.8; //Size int AtrPeriod=100; // ATR Period double AtrAlpha=2.0/(AtrPeriod+1.0); double Size1=1.0; double Size2=1.25; double Size3=1.5; double Size4=1.75; double Size5=2.0; double Size6=2.25; //---- will be used as indicator buffers double STEP1[]; double STEP2[]; double STEP3[]; double STEP4[]; double STEP5[]; double STEP6[]; double CLR1[]; double CLR2[]; double CLR3[]; double CLR4[]; double CLR5[]; double CLR6[]; double TREND[]; double CLR[]; double ATR[]; int min_rates_total; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //---- Initialization of variables of data calculation starting point min_rates_total=2; //--- indicator buffers int i=0; SetIndexBuffer(i++,TREND,INDICATOR_DATA); SetIndexBuffer(i++,CLR,INDICATOR_COLOR_INDEX); SetIndexBuffer(i++,STEP1,INDICATOR_DATA); SetIndexBuffer(i++,CLR1,INDICATOR_COLOR_INDEX); SetIndexBuffer(i++,STEP2,INDICATOR_DATA); SetIndexBuffer(i++,CLR2,INDICATOR_COLOR_INDEX); SetIndexBuffer(i++,STEP3,INDICATOR_DATA); SetIndexBuffer(i++,CLR3,INDICATOR_COLOR_INDEX); SetIndexBuffer(i++,STEP4,INDICATOR_DATA); SetIndexBuffer(i++,CLR4,INDICATOR_COLOR_INDEX); SetIndexBuffer(i++,STEP5,INDICATOR_DATA); SetIndexBuffer(i++,CLR5,INDICATOR_COLOR_INDEX); SetIndexBuffer(i++,STEP6,INDICATOR_DATA); SetIndexBuffer(i++,CLR6,INDICATOR_COLOR_INDEX); SetIndexBuffer(i++,ATR,INDICATOR_DATA); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- int first; if(rates_total<=min_rates_total) return(0); //--- //+----------------------------------------------------+ //|Set Median Buffeer | //+----------------------------------------------------+ int begin_pos=min_rates_total; first=begin_pos; if(firststep[i-1]) step[i]=price-size; else if((price+size)step[i-1]) step[i]=price-size; else if((price+size)step[i-1])clr[i]=0; else if(step[i]