Help with simple custom indicator
Pardon my not using the SRC button, this was my first post on the forums.
kenny, I did add the IndicatorBuffers(5); but still can't seem to produce a functional line of that quotient on the graph.
Here is the updated code...
//+------------------------------------------------------------------+ //| CIND.mq4 | //| John Reynolds | //+--------------------------------------- ---------------------------+ #property copyright "John Reynolds" #property indicator_separate_window #property indicator_minimum 0.985 #property indicator_maximum 1.015 #property indicator_buffers 1 #property indicator_color1 Orange extern int EMA_period=14; double CIND[]; double Ema[]; double EmaOfEma[]; double EmaOfEmaOfEma[]; double Tema[]; int init() { IndicatorBuffers(5); SetIndexBuffer(0,CIND); SetIndexBuffer(1,Ema); SetIndexBuffer(2,EmaOfEma); SetIndexBuffer(3,EmaOfEmaOfEma); SetIndexBuffer(4,Tema); SetIndexStyle(0,DRAW_LINE); SetIndexLabel(0,"CIND"); return(0); } int start() { int i,limit,limit2,limit3,counted_bars=IndicatorCounted(); double Price = Bid; if (counted_bars==0) { limit=Bars-1; limit2=limit-EMA_period; limit3=limit2-EMA_period; } if (counted_bars>0) { limit=Bars-counted_bars-1; limit2=limit; limit3=limit2; } for (i=limit;i>=0;i--) Ema[i]=iMA(NULL,0,EMA_period,0,MODE_EMA,PRICE_CLOSE,i); for (i=limit2;i>=0;i--) EmaOfEma[i]=iMAOnArray(Ema,0,EMA_period,0,MODE_EMA,i); for (i=limit3;i>=0;i--) EmaOfEmaOfEma[i]=iMAOnArray(EmaOfEma,0,EMA_period,0,MODE_EMA,i); for (i=limit3;i>=0;i--) Tema[i]=3*Ema[i]-3*EmaOfEma[i]+EmaOfEmaOfEma[i]; CIND[i] = (Price/Tema[i]); return(0); }
Essentially all the code within int start() is the code for the Triple Exponential Moving Average. After producing that figure, I believe the problem to be taking that figure and placing it in a quotient below the current bid price - I attempted to do this with the CIND[i] = (Price/Tema[i]) function.
Again, any further help would be
most appreciated, thanks...
Hi, I'm simply trying to create a custom indicator that produces the simple quotient of (current bid / current triple exponential moving average figure).
Any help on making this functional would be most appreciated. Thanks for your time...
//+------------------------------------------------------------------+
//| CIND.mq4 |//| John Reynolds |
//+--------------------------------------- ---------------------------+
#property copyright "John Reynolds"
#property indicator_separate_window
#property indicator_minimum 0.985
#property indicator_maximum 1.015
#property indicator_buffers 1
#property indicator_color1 Orange
extern int EMA_period=14;
double CIND[];
double Ema[];
double EmaOfEma[];
double EmaOfEmaOfEma[];
double Tema[];
int init()
{
SetIndexBuffer(0,CIND);
SetIndexBuffer(1,Ema);
SetIndexBuffer(2,EmaOfEma);
SetIndexBuffer(3,EmaOfEmaOfEma);
SetIndexBuffer(4,Tema);
SetIndexStyle(0,DRAW_LINE);
SetIndexLabel(0,"CIND");
return(0);
}
int start()
{
int i,limit,limit2,limit3,counted_bars=IndicatorCounted();
double Price = Bid;
if (counted_bars==0)
{
limit=Bars-1;
limit2=limit-EMA_period;
limit3=limit2-EMA_period;
}
if (counted_bars>0)
{
limit=Bars-counted_bars-1;
limit2=limit;
limit3=limit2;
}
for (i=limit;i>=0;i--) Ema[i]=iMA(NULL,0,EMA_period,0,MODE_EMA,PRICE_CLOSE,i);
for (i=limit2;i>=0;i--) EmaOfEma[i]=iMAOnArray(Ema,0,EMA_period,0,MODE_EMA,i);
for (i=limit3;i>=0;i--) EmaOfEmaOfEma[i]=iMAOnArray(EmaOfEma,0,EMA_period,0,MODE_EMA,i);
for (i=limit3;i>=0;i--) Tema[i]=3*Ema[i]-3*EmaOfEma[i]+EmaOfEmaOfEma[i];
CIND[i] = (Price/Tema[i]);
return(0);
}