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
Please see code below the attached picture. I appreciate the help.
//+------------------------------------------------------------------+
//| ATR Channels. mq4 |
//| Copyright © 2005, Luis Guilherme Damiani |
//| http://www.damianifx.com.br |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Luis Guilherme Damiani"
#property link "http://www.damianifx.com.br"
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 0 //Moving Average
#property indicator_color2 MediumPurple // Lower band 1
#property indicator_color3 MediumPurple // Upper band 1
//---- indicator buffers
double MA_Buffer0[];
double Ch1up_Buffer1[];
double Ch1dn_Buffer2[];
//---- input parameters
extern int PeriodsATR = 20;
extern int MA_Periods = 1;
extern int MA_type = MODE_OPEN;
extern double Mult_Factor1 = 0.7;
extern double Mult_Factor2 = 0.0;
extern double Mult_Factor3 = 0.0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string mat;
//---7- indicators
// MA
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, MA_Buffer0);
SetIndexDrawBegin(0, MathMax(PeriodsATR, MA_Periods));
// ATR 1 up
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, Ch1up_Buffer1);
SetIndexDrawBegin(1, MathMax(PeriodsATR, MA_Periods));
string sATRu1 = StringConcatenate("ATRu(", PeriodsATR, ", ", Mult_Factor1, ")");
SetIndexLabel(1, sATRu1);
// ATR 1 down
SetIndexStyle(2, DRAW_LINE);
SetIndexBuffer(2, Ch1dn_Buffer2);
SetIndexDrawBegin(2, MathMax(PeriodsATR, MA_Periods));
string sATRd1 = StringConcatenate("ATRd(", PeriodsATR, ", ", Mult_Factor1, ")");
SetIndexLabel(2, sATRd1);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
if(Bars <= MathMax(PeriodsATR, MA_Periods))
return(0);
int fixed_bars = IndicatorCounted();
//---- check for possible errors
if(fixed_bars < 0)
return(-1);
//---- last counted bar will be recounted
if(fixed_bars > 0)
fixed_bars--;
int limit = Bars - fixed_bars;
//----
for(int i = 0; i < limit; i++)
{
double atr = iATR(NULL, 0, PeriodsATR, i);
double ma = iMA(NULL, 0, MA_Periods, 0, MA_type, PRICE_OPEN, i);
MA_Buffer0[i] = ma;
Ch1up_Buffer1[i] = ma + atr*Mult_Factor1; //<<<------------THIS IS WHAT I'M TRYING TO DISPLAY.
Ch1dn_Buffer2[i] = ma - atr*Mult_Factor1; //<<<------------THIS TOO.
}
//----
return(0);
}
//+------------------------------------------------------------------+