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've been trying to code this MA. I'm using 5 different Arrays: 3 for loading the 3 MA points, and 2 for the arrows signal.
But i really can't load the MA points into the ShortBuffer[], MediumBuffer[] and LongBuffer[]. When i test it what i get is always 0 for every [i] value. I don't know what i'm doing wrong. Can anyone help me with this.
Many thanks in advance.
I show you my code:
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
extern int ShortPeriod = 5;
extern int ShortPeriodMethod = 0; //0=sma, 1=ema, 2=smma, 3=lwma
extern int ShortPeriodApplyTo = 0; //0=PRICE_CLOSE, 1=PRICE_OPEN, 2=PRICE_HIGH, 3=PRICE_LOW, 4=PRICE_MEDIAN, 5=PRICE_TYPICAL, 6=PRICE_WEIGHTED
extern int MediumPeriod = 20;
extern int MediumPeriodMethod = 0; //0=sma, 1=ema, 2=smma, 3=lwma
extern int MediumPeriodApplyTo = 0; //0=PRICE_CLOSE, 1=PRICE_OPEN, 2=PRICE_HIGH, 3=PRICE_LOW, 4=PRICE_MEDIAN, 5=PRICE_TYPICAL, 6=PRICE_WEIGHTED
extern int LongPeriod = 50;
extern int LongPeriodMethod = 0; //0=sma, 1=ema, 2=smma, 3=lwma
extern int LongPeriodApplyTo = 0; //0=PRICE_CLOSE, 1=PRICE_OPEN, 2=PRICE_HIGH, 3=PRICE_LOW, 4=PRICE_MEDIAN, 5=PRICE_TYPICAL, 6=PRICE_WEIGHTED
//---- input parameters
//---- buffers
double UpBuffer[];
double DnBuffer[];
double ShortBuffer[];
double MediumBuffer[];
double LongBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW,EMPTY,1);
SetIndexBuffer(0,UpBuffer);
SetIndexArrow(0,233);
SetIndexLabel(0,"Up Signal");
SetIndexStyle(1,DRAW_ARROW,EMPTY,1);
SetIndexBuffer(1,DnBuffer);
SetIndexArrow(1,234);
SetIndexLabel(1,"Down Signal");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- the last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- main loop
for(int i=0; i<limit; i++)
{
ShortBuffer[i]= iMA(NULL,0,ShortPeriod,0,ShortPeriodMethod,ShortPeriodApplyTo,i);
MediumBuffer[i]= iMA(NULL,0,MediumPeriod,0,MediumPeriodMethod,MediumPeriodApplyTo,i);
LongBuffer[i]= iMA(NULL,0,LongPeriod,0,ShortPeriodMethod,ShortPeriodApplyTo,i);
...
...
}
return(0);
}