Price Data Components
Indicators Used
Miscellaneous
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 Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---