texcs:
How are declared your arrays ?
[10:50:01] Teodoro Nato:
in the following way
double MovingAvarage20[],MovingAvarage40[],MovingAvarage50[]; double ma20[], ma40[], ma50[];
Where are you resizing them?
give me an example thanks
a great example already exist in the Docs ArrayResize
ok, but why should not resized if I gave him greatness?
i did the modify as your suggestion, the mistake seem resolved but after the restart on "mt4" the program goes on crash and i have to restart again, Here is the code:
int trendUp=0,trendDown=0; double MovingAvarage20[],MovingAvarage40[],MovingAvarage50[]; double ma20[], ma40[], ma50[]; int counted_bars = IndicatorCounted(); int limit=Bars-counted_bars; //---- check for possible errors if(counted_bars < 0) return(-1); //---- last counted bar will be recounted if(counted_bars > 0) counted_bars--; ArrayResize(MovingAvarage20,5);ArrayResize(ma20,5); ArrayResize(MovingAvarage40,5);ArrayResize(ma40,5); ArrayResize(MovingAvarage50,5);ArrayResize(ma50,5); //creo l'array dei valori delle ultime 5 candele delle medie for ( int i=0; i< 5; i++) { //creo l'array dei valori delle ultime 5 candele della media a 20 periodi MovingAvarage20[i]= iMA(NULL, 0, PeriodMovingAvarage20,0, MODE_EMA, PRICE_CLOSE,i); ma20[i]= MovingAvarage20[i]; //creo l'array dei valori delle ultime 5 candele della media a 40 periodi MovingAvarage40[i]= iMA(NULL, 0, PeriodMovingAvarage40,0, MODE_EMA, PRICE_CLOSE,i); ma40[i]= MovingAvarage40[i]; //creo l'array dei valori delle ultime 5 candele della media a 50 periodo MovingAvarage50[i]= iMA(NULL, 0, PeriodMovingAvarage50,0, MODE_EMA, PRICE_CLOSE,i); ma50[i]= MovingAvarage50[i]; if ((ma20[i] > ma40[i] ) && (ma40[i] > ma50[i])) trendUp++; if ((ma20[i] < ma40[i]) && (ma40[i]< ma50[i])) trendDown++; }
What value are you giving PeriodMovingAvarage20 etc
This seems odd anyway
MovingAvarage20[i]= iMA(NULL, 0, PeriodMovingAvarage20,0, MODE_EMA, PRICE_CLOSE,i);
Why not simply
MovingAvarage20[i]= iMA(NULL, 0,20,0, MODE_EMA, PRICE_CLOSE,i);
input int PeriodMovingAvarage20=20; input int PeriodMovingAvarage40=40; input int PeriodMovingAvarage50=50;
To make it easier to edit

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
[10:50:01] Teodoro Nato:
I created an index but when i mark the MovingmAverage" what happends is: The index works, but if i fill the mistake do not appear but if i "Attach"to the graph the errors is "array out of rage"