Fractal_channels_milko

Author: Mikko
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Indicators Used
Fractals
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Fractal_channels_milko
//+------------------------------------------------------------------+
//|                                             Fractal Channels     |
//|                                                            Mikko |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Mikko"
#property link      "http://www.currencylabs.com"

//#property indicator_separate_window
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Silver
#property indicator_color2 Silver
#property indicator_color3 Red
#property indicator_color4 Gray
#property indicator_color5 Gray

double high[];
double low[];
double middle[];

extern int period.tf = 0;

int init() {

   IndicatorBuffers(5);
   SetIndexBuffer(0, high);   
   SetIndexStyle(0, DRAW_LINE, EMPTY, 1); 
   
   SetIndexBuffer(1, low);     
   SetIndexStyle(1, DRAW_LINE, EMPTY, 1);
   
   SetIndexBuffer(2, middle);     
   SetIndexStyle(2, DRAW_LINE, EMPTY, 1);

   IndicatorShortName("Mikko fractal channels");
   
   if(period.tf == 0)
      period.tf = Period();
      
   return(0);
}
  
int deinit() {
   return(0);
}
     
int start() {
       
   int counted_bars=IndicatorCounted();
  
   if(counted_bars < 0) 
       return(-1);
   if(counted_bars > 0) 
       counted_bars--;
       
   int limit = Bars - counted_bars;
    
   
   for(int i = limit; i >= 0; i--) {
   
       int s = iBarShift(Symbol(), period.tf, Time[i], true); // next in future bar minus 1 bar -> this close bar
       
       if(s == -1) {
         high[i] = high[i+1];
         low[i] = low[i+1];
         middle[i] = middle[i+1];
        
       } else {

         double upper = iFractals(Symbol(),period.tf,MODE_UPPER,s+3);
         double lower = iFractals(Symbol(),period.tf,MODE_LOWER,s+3);

         if(upper != 0)
            high[i] = iHigh(Symbol(),period.tf,s+3);
         else
            high[i] = high[i+1];            
            
         if(lower != 0)
            low[i] = iLow(Symbol(),period.tf,s+3);
         else
            low[i] = low[i+1];            
            
         middle[i] = (high[i]+low[i])/2;   
     
       }
   } 
   return(0);
}

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 ---