Picture

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi Everyone I'm new to MT.
Could someone help me with these Keltner Channels?
They don't plot all.....lines?
Thanks in advanced, appridiated!
Maurice
P.S. Attachment is a picture from another platform....
//+------------------------------------------------------------------+
//| Keltner Channels.mq4 |
//| Coded by Gilani |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Black
#property indicator_color2 DimGray
#property indicator_color3 Red
#property indicator_color4 DimGray
#property indicator_color5 Black
double upper2[], upper1[], middle[], lower1[], lower2[];
extern int period = 20;
int init()
{
SetIndexStyle(1,DRAW_LINE);
SetIndexShift(2,0);
SetIndexDrawBegin(1,0);
SetIndexBuffer(1,upper2);
SetIndexStyle(2,DRAW_LINE);
SetIndexShift(1,0);
SetIndexDrawBegin(2,0);
SetIndexBuffer(2,upper1);
SetIndexStyle(3,DRAW_LINE);
SetIndexShift(0,0);
SetIndexDrawBegin(3,0);
SetIndexBuffer(3,middle);
SetIndexStyle(4,DRAW_LINE);
SetIndexShift(-1,0);
SetIndexDrawBegin(4,0);
SetIndexBuffer(4,lower1);
SetIndexStyle(5,DRAW_LINE);
SetIndexShift(-2,0);
SetIndexDrawBegin(5,0);
SetIndexBuffer(5,lower2);
return(0);
}
int deinit(){return(0);}
int start() {
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
double avg;
for(int x=0; x<limit; x++) {
middle[x] = iMA(NULL, 0, period, 0, MODE_SMA, PRICE_CLOSE, x);
avg = findAvg(period, x);
upper2[x] = middle[x] + avg;
upper1[x] = middle[x] + avg;
lower1[x] = middle[x] - avg;
lower2[x] = middle[x] - avg;
}
return(0);
}
//+------------------------------------------------------------------+
double findAvg(int period, int shift) {
double sum=0;
for (int x=shift;x<(shift+period);x++) {
sum += High[x]-Low[x];
}
sum = sum/period;
return (sum);
}