why the value of them is zero - page 2

 

Dear friends:

Do you know how to implement it?

thanks!

 

Does anyone can help me?

thanks!

 
sniff:

thank your help, the value of RSV is correct.there is another question,please see the code.

the percentK[i] value is -0,why?

double percentK[512];

double RSV[512];

limit=Bars-counted_bars;
if(limit > 512) limit = 512;
//---- signal line is simple movimg average
for(i=0; i<limit; i++)
{
percentK[i]=iMAOnArray(RSV,Bars,M1,0,MODE_SMA,i);
}

Bars is going to be greater than limit for H1 and smaller timeframes, so why are you using Bars in your iMAOnArray ? also in that call, what is M1 ? You need to look carefully at the syntax for https://docs.mql4.com/indicators/iMAOnArray

 
Hmm, I'm Noob but I'll take a crack at it

Thinking out loud and put to text just to see if I can understand this logic

Where did you put your print statements to see this value of -0 ? in the loops, after the loop before the loop ?

The for loop terminates when i++ = limit which is set to 512
so the condition becomes false when i==512 right ?

And so iMAOnArray(RSV,Bars,M1,0,MODE_SMA,i); what is RSV ?

double iMAOnArray( double array[], int total, int period, int ma_shift, int ma_method, int shift)

Shouldn't this be (RSV[], or perhaps ( RSV[512].... or something

So in this case percentK[i]=iMAOnArray(RSV,Bars,M1,0,MODE_SMA,i) should produce 0 value if it's expecting an array RSA[] or RSA[i] or something ?


Anyhow thats what I'm coming up with as my NooB logic would provide

And of course what RapturUK suggested about the the syntax as well PERIOD_M1, PERIOD_H1 etc. OR use 0 to select the current time frame


Hope this helps
 
Agent86:

And of course what RapturUK suggested about the the syntax as well PERIOD_M1, PERIOD_H1 etc. OR use 0 to select the current time frame

In iMAOnArray period refers to a number of bars not a timeframe, i.e. "Averaging period for calculation."
 

thank you, all friends!

the code which has been attached is a part.

the logic is as follow:

1)define two global array RSV and RSV,

2)calculate the value of RSV element, because the size of RSV is 512,if the bars of chart has more than 512, calculate the last 512 bars.

3)calculate the value of percentK by simple moving average

4)print the value of percentK,but the value of them is -0.

if the logic is clear?

By the way, you mean the first parameter should not be RSV?

thanks!

 
sniff:
3)calculate the value of percentK by simple moving average
4)print the value of percentK,but the value of them is -0.
  1. The second parameter to imaOnArray is the size of the array, not bars. Zero means the whole array.
  2. The first parameter to imaOnArray is the array you're averaging. You Don't set any values into it in the code you posted. The MA of zeroes is zero.
  3. limit=Bars-counted_bars;
    Initially counted_bars (fromIndicatorCounted()) will be zero so you are accessing beyond the arrays. Limit=Bars-1-counted_bars;
 

Доброго времени суток уважаемые форумчане!

Меня зовут Герман, мне 23 года, я являюсь трейдером компании "Инстафорекс"

Помогите в поиске нужного скрипта! Скрипт нужен для сетки отложенных ордеров.

 

Dear friends:

thank you very much!

thanks!

Reason: