//+------------------------------------------------------------------+ //| Custom_Pattern.mq5 | //| Copyright 2018, MetaQuotes Software Corp. | //| https://mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2018, MetaQuotes Software Corp." #property link "https://mql5.com" #property version "1.00" #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 #property description "The indicator provides the user to" #property description "specify a custom format pattern candle" #property description "and draws patterns on the chart" #property description "------------------------------------" #property description "U - UP candle (Close>Open)" #property description "D - DOWN candle (Close1) { limit=rates_total-length-1; ArrayInitialize(BufferDIR,EMPTY_VALUE); ArrayInitialize(BufferREV,EMPTY_VALUE); } //--- Расчёт индикатора for(int i=limit; i>=0 && !IsStopped(); i--) { if(DirectPattern(i,open,close)) BufferDIR[i]=high[i]; if(InpShowReverce && ReversePattern(i,open,close)) BufferREV[i]=low[i]; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool DirectPattern(const int shift,const double &open[],const double &close[]) { string s=""; //string Pat=StringTrimLeft(StringTrimRight(Pattern)); bool f=true; for(int i=1; i<=length; i++) { s=CharToString(array[length-i]);//StringSubstr(Pat,LengthPattern-i,1); if((s=="u") && (close[shift+i-1]<=open[shift+i-1])) f=false; if((s=="d") && (close[shift+i-1]>=open[shift+i-1])) f=false; } return f; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool ReversePattern(const int shift,const double &open[],const double &close[]) { string s=""; //string Pat=StringTrimLeft(StringTrimRight(Pattern)); bool f=true; for(int i=1; i<=length; i++) { s=CharToString(array[length-i]);//StringSubstr(Pat,LengthPattern-i,1); if((s=="u") && (close[shift+i-1]>=open[shift+i-1])) f=false; if((s=="d") && (close[shift+i-1]<=open[shift+i-1])) f=false; } return f; } //+------------------------------------------------------------------+