Hi,
I wish I was a coder... anyway this is a very simple indicator I wrote, but I can not get it to print ExtMapBuffer1 or ExtMapBuffer2, also called the channel lines. ExtMapBuffer3 prints fine, which is the ma in the middle. What am I missing?
I am wanting to draw a simple ma channel based upon a set pipcount, with the ma line in the middle.
Thanks for any help,
Doug Carr
//+------------------------------------------------------------------+
//| TestIdea.mq4 |
//| Doug Carr |
//| http://www.carrsthisnthat.com |
//+------------------------------------------------------------------+
#property copyright "Doug Carr"
#property link "http://www.carrsthisnthat.com"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Goldenrod
#property indicator_color2 Goldenrod
#property indicator_color3 Aqua
//---- input parameters
extern int MaPeriod=10;
extern double PipDifference=20;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtMapBuffer3);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted(),limit;
if(counted_bars>0)counted_bars--;
limit=Bars-counted_bars;
for(int i=0;i<limit;i++)
{
double myMA=iMA(NULL,0,MaPeriod,0,MODE_SMA,PRICE_CLOSE,i);
ExtMapBuffer1[i]=(myMA+PipDifference);
ExtMapBuffer2[i]=(myMA-PipDifference);
ExtMapBuffer3[i]=myMA;
//----
//----
}
return(0);
}
//+------------------------------------------------------------------+
I wish I was a coder... anyway this is a very simple indicator I wrote, but I can not get it to print ExtMapBuffer1 or ExtMapBuffer2, also called the channel lines. ExtMapBuffer3 prints fine, which is the ma in the middle. What am I missing?
I am wanting to draw a simple ma channel based upon a set pipcount, with the ma line in the middle.
Thanks for any help,
Doug Carr
//+------------------------------------------------------------------+
//| TestIdea.mq4 |
//| Doug Carr |
//| http://www.carrsthisnthat.com |
//+------------------------------------------------------------------+
#property copyright "Doug Carr"
#property link "http://www.carrsthisnthat.com"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Goldenrod
#property indicator_color2 Goldenrod
#property indicator_color3 Aqua
//---- input parameters
extern int MaPeriod=10;
extern double PipDifference=20;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtMapBuffer3);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted(),limit;
if(counted_bars>0)counted_bars--;
limit=Bars-counted_bars;
for(int i=0;i<limit;i++)
{
double myMA=iMA(NULL,0,MaPeriod,0,MODE_SMA,PRICE_CLOSE,i);
ExtMapBuffer1[i]=(myMA+PipDifference);
ExtMapBuffer2[i]=(myMA-PipDifference);
ExtMapBuffer3[i]=myMA;
//----
//----
}
return(0);
}
//+------------------------------------------------------------------+