Support_and_Resistance_-_barry

Author: © mladen, 2016, MetaQuotes Software Corp.
0 Views
0 Downloads
0 Favorites
Support_and_Resistance_-_barry
ÿþ//------------------------------------------------------------------

#property copyright   "© mladen, 2016, MetaQuotes Software Corp."

#property link        "www.forex-tsd.com, www.mql5.com"

//------------------------------------------------------------------

#property indicator_chart_window

#property indicator_buffers 4

#property indicator_plots   3

#property indicator_type1   DRAW_FILLING

#property indicator_color1  clrGainsboro,clrGainsboro

#property indicator_type2   DRAW_LINE

#property indicator_color2  clrMediumTurquoise

#property indicator_width2  2

#property indicator_type3   DRAW_LINE

#property indicator_color3  clrTan

#property indicator_width3  2



//

//

//

//

//



input int FractalPeriod=25; // Fractals period



//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//



double res[],sup[],fup[],fdn[];

void OnInit()

{

   SetIndexBuffer(0,fup,INDICATOR_DATA);

   SetIndexBuffer(1,fdn,INDICATOR_DATA);

   SetIndexBuffer(2,res,INDICATOR_DATA);

   SetIndexBuffer(3,sup,INDICATOR_DATA);

}

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 k,half = FractalPeriod/2; double compareTo;

   for (int i=(int)MathMax(prev_calculated-half,half); i<rates_total && !_StopFlag; i++)

   {

         compareTo = high[i];

            for (k=1;k<=half && (i+k)<rates_total ;k++)

            {

               if (high[i+k]> compareTo) break;

               if (high[i-k]>=compareTo) break;

            }

            double fractalUp = (k==half+1) ? high[i] : EMPTY_VALUE;

         compareTo = low[i];

            for (k=1;k<=half && (i+k)<rates_total ;k++)

            {

               if (low[i+k]< compareTo) break;

               if (low[i-k]<=compareTo) break;

            }

            double fractalDn = (k==half+1) ? high[i] : EMPTY_VALUE;

         

            //

            //

            //

            //

            //

         

            res[i] = (fractalUp != EMPTY_VALUE) ? high[i] : (i>0) ? res[i-1] : high[i]; fup[i] = res[i];

            sup[i] = (fractalDn != EMPTY_VALUE) ? low[i]  : (i>0) ? sup[i-1] : low[i] ; fdn[i] = sup[i];

   }  

   return(rates_total);

}

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---