//+------------------------------------------------------------------+ //| TangoLine_v1.2.mq4 | //| TangoLine v1.2 Copyright 2015, fxborg | //| http://fxborg-labo.hateblo.jp/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, fxborg" #property link "http://fxborg-labo.hateblo.jp/" #property version "1.2" #property strict #property indicator_chart_window #property indicator_buffers 5 //--- plot Label1 #property indicator_label1 "TangoLine" #property indicator_type1 DRAW_LINE #property indicator_type2 DRAW_LINE #property indicator_type3 DRAW_LINE #property indicator_type4 DRAW_ARROW #property indicator_type5 DRAW_ARROW //--- #property indicator_color1 DeepPink #property indicator_color2 DarkViolet #property indicator_color3 DarkViolet #property indicator_color4 Red #property indicator_color5 Blue #property indicator_label1 "TangoLine" #property indicator_label2 "Upper Channel" #property indicator_label3 "Lower Channel" #property indicator_label4 "Reversal Bar" #property indicator_label5 "Reversal Bar" //--- #property indicator_width1 2 #property indicator_width2 1 #property indicator_width3 1 #property indicator_width4 2 #property indicator_width5 2 #property indicator_style1 STYLE_SOLID #property indicator_style2 STYLE_DASH #property indicator_style3 STYLE_DASH //--- input parameters input int InpPeriod=20; // Channel Period input double InpReversalNoiseFilter=5; // NoiseFilter (Minimam Reversal Spread) double RevNoiseFilter=InpReversalNoiseFilter*Point; //--- int min_rates_total; //--- indicator buffers double LineBuffer[]; double HighBuffer[]; double LowBuffer[]; double TopBuffer[]; double BtmBuffer[]; //---- for calc double HighesBuffer[]; double LowesBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //---- Initialization of variables of data calculation starting point min_rates_total=1+InpPeriod+1; //--- indicator buffers mapping IndicatorBuffers(14); //--- indicator buffers SetIndexBuffer(0,LineBuffer); SetIndexBuffer(1,HighBuffer); SetIndexBuffer(2,LowBuffer); SetIndexBuffer(3,TopBuffer); SetIndexBuffer(4,BtmBuffer); //--- calc buffers SetIndexBuffer(5,HighesBuffer); SetIndexBuffer(6,LowesBuffer); SetIndexArrow(3,159); SetIndexArrow(4,159); SetIndexShift(0,1); SetIndexShift(1,1); SetIndexShift(2,1); //--- string short_name="Tango Line v1.2("+IntegerToString(InpPeriod)+")"; IndicatorShortName(short_name); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| De-initialization | //+------------------------------------------------------------------+ int deinit() { string short_name="Tango Line v1.2("+IntegerToString(InpPeriod)+")"; IndicatorShortName(short_name); return(0); } //+------------------------------------------------------------------+ //| 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 i,j,k,first; //--- check for bars count if(rates_total<=min_rates_total) return(0); //--- indicator buffers ArraySetAsSeries(LineBuffer,false); ArraySetAsSeries(HighBuffer,false); ArraySetAsSeries(LowBuffer,false); ArraySetAsSeries(TopBuffer,false); ArraySetAsSeries(BtmBuffer,false); //--- calc buffers ArraySetAsSeries(HighesBuffer,false); ArraySetAsSeries(LowesBuffer,false); //--- rate data ArraySetAsSeries(high,false); ArraySetAsSeries(low,false); //+----------------------------------------------------+ //|Set High Low Buffeer | //+----------------------------------------------------+ first=InpPeriod-1; if(first+1low[k]) dmin=low[k]; if(dmax1;j--) { if(LowesBuffer[j-2]-RevNoiseFilter*Point>LowesBuffer[j-1] && LowesBuffer[j-1]==LowesBuffer[j]) { //--- reversal of top btm_pos=j-1; BtmBuffer[btm_pos]=LowesBuffer[btm_pos]; break; } //--- reversal of bottom if(HighesBuffer[j-2]+RevNoiseFilter*Pointlow[j])range_lo=low[j]; } //--- set channel data double prev_high=MathMax(MathMax(MathMax(high[turn_pos-4], high[turn_pos-3]),high[turn_pos-2]),high[turn_pos-1]); double prev_low=MathMin(MathMin(MathMin(low[turn_pos-4], low[turn_pos-3]),low[turn_pos-2]),low[turn_pos-1]); HighBuffer[i]=MathMax(range_hi,prev_high); LineBuffer[i]=(range_hi+range_lo)/2; LowBuffer[i]=MathMin(range_lo,prev_low); } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+