static array ? - page 6

 

Too much code in that plain English description . . .

The Fractals are stored in the Indicator buffers, do you understand how ? if you don't write some code to help you understand . . .

You can read the Indicator buffers and find the bar numbers fro the Fractals, from the bar number you can get the candle values . . .

 
RaptorUK:

Too much code in that plain English description . . .

The Fractals are stored in the Indicator buffers, do you understand how ? if you don't write some code to help you understand . . .

You can read the Indicator buffers and find the bar numbers fro the Fractals, from the bar number you can get the candle values . . .

I do not completely understand how the indicator buffers are stored.


And this is exactly what I wanted to do, find the bar number, from the fractals and get the candle values

I'll keep on with it, but I would likely be more clear about it if I knew how the indicators are storing the values in the buffer.

Thanks

 

There are 3 buffers, v1, v2 & v3 and there are three other doubles, val1, val2 & val3, used for calculating. v3 and val3 don't seem to be used . . .

val1 and val2 hold the value produced by iFractals, this value is calculated for each bar one by one, the while loop loops through the bars starting with Bars and decrementing all the way to zero . . .

So for each bar the fractals value is calculated and stored in v1 for MODE_UPPER and v2 for MODE_LOWER, lets work through for v1 . . .

For each bar in turn . . . if val1 is greater than 0 the buffer value for buffer v1 for the bar number is set to the High of that bar, so imagine the loop is part way through the bars from Bars to 0, lets imagine it is on bar number 4934, the fractal is calculated for bar number 4934, if the value is greater than 0 then v1[4934] is set to High[4934], in other words the 4935th element of the v1 buffer is set to the high of the bar number 4934 . . . don't forget Arrays start at 0

Finally there is a small complication you need to understand . . . run the indicator and you will see a line of dots from each fractal high and low . . until the next one . . Imagine we are now on bar number 4933 and the value of val1 is not greater than 0, what happens now is that the buffer value for this bar is not set to this bars High but is set to the same value as the previous entry for the buffer . . previous in this case means i+1 because in the while loop i is counting down.

When the loop ends and all bars have had their fractals calculated all entries in the buffers will contain values . . . this isn't much help to you . . . you need to change the code a little.

Read what I have written here . . . if you don't understand what is going on then you have no business messing with this code . . . once you understand then you can move forward . . . any questions please ask.

 
RaptorUK:

There are 3 buffers, v1, v2 & v3 and there are three other doubles, val1, val2 & val3, used for calculating. v3 and val3 don't seem to be used . . .

val1 and val2 hold the value produced by iFractals, this value is calculated for each bar one by one, the while loop loops through the bars starting with Bars and decrementing all the way to zero . . .

So for each bar the fractals value is calculated and stored in v1 for MODE_UPPER and v2 for MODE_LOWER, lets work through for v1 . . .

For each bar in turn . . . if val1 is greater than 0 the buffer value for buffer v1 for the bar number is set to the High of that bar, so imagine the loop is part way through the bars from Bars to 0, lets imagine it is on bar number 4934, the fractal is calculated for bar number 4923, if the value is greater than 0 then v1[4394] is set to High[4394], in other words the 4395th element of the v1 buffer is set to the high of the bar number 4394 . . . don't forget Arrays start at 0

Finally there is a small complication you need to understand . . . run the indicator and you will see a line of dots from each fractal high and low . . until the next one . . Imagine we are now on bar number 4933 and the value of val1 is not greater than 0, what happens now is that the buffer value for this bar is not set to this bars High but is set to the same value as the previous entry for the buffer . . previous in this case means i+1 because in the while loop i is counting down.

When the loop ends and all bars have had their fractals calculated all entries in the buffers will contain values . . . this isn't much help to you . . . you need to change the code a little.

Read what I have written here . . . if you don't understand what is going on then you have no business messing with this code . . . once you understand then you can move forward . . . any questions please ask.

I do understand how the indicator is working exactly as you described it. I thought I understood also how the buffer was storing the values, which is why I was getting confused because when I re-code things to print I did not get the results I was expected to see.

However, a major major hurdle has now been overcome with understanding how the buffer is different and NOT actually declared the number of elements which is why I could not print from the buffer

Ok moving on.
I'm assuming there is some typo's in your references to bar number 4934, fractal is calculated for bar number 4923 and should read 4933.
And also for value greater then 0 then v1[4394] is set to High[4394] == I'm assuming is meant to follow the previous reference to 4923/33 as well but I understand that it's the element number is higher then the Bar number.

Please correct me if I'm wrong about the typo's.

Anyhow assuming these are typo's and I understand what this means.

I considered that I would create v3 and declare it and initialize it in a similar way in order to be able to print it or get the value from it.
I had initially considered that I might be able to print i-1 to extract the stored value of the High[i] at the time that it was greater then 0 and for that Bar.
Or even v1[i] = v1[1-1] and Print v1[i] at this time, but I have not worked that part out and also could not get past the printing part since the number of elements was not declared.

This is why I wanted to create a different v3 scheme but actually the same just to create an array with declared number of element which I might extract the value of the fractals for those bars.

This is where I'm having trouble with design, so I'll work through it some more

Thanks

 
Agent86:

I do understand how the indicator is working exactly as you described it. I thought I understood also how the buffer was storing the values, which is why I was getting confused because when I re-code things to print I did not get the results I was expected to see.

However, a major major hurdle has now been overcome with understanding how the buffer is different and NOT actually declared the number of elements which is why I could not print from the buffer

Ok moving on.
I'm assuming there is some typo's in your references to bar number 4934, fractal is calculated for bar number 4923 and should read 4933.
And also for value greater then 0 then v1[4394] is set to High[4394] == I'm assuming is meant to follow the previous reference to 4923/33 as well but I understand that it's the element number is higher then the Bar number.

Please correct me if I'm wrong about the typo's.

Sorry about the typos . . . I have fixed my text with the correct values . . . I'm not good first thing of a morning ;-)

Do you see the small modification that you need to make to the code before it is of much use to you ?

 
    for(i=Bars; i >= 0; i--)
     {
     val3=iFractals(NULL, 0, MODE_UPPER,i);
     if(val3>0)
      {
      double v3[1000];
      v3[i]=High[i];
      Print ("v3[", i, "]= ", v3[i], " if");
      }
     else          
         {
         v3[i]=v3[i+1];
         Print ("v3[", i, "]= ", v3[i], " else");
         }
     }
Ok making some progress here, I think the main thing was that I could not get past the declaration of the buffer which always produced 0 for my print statments.

I think I might be able to handle from here
I'm getting the values that I seek now at least from what I can tell so far I may be on the right track.

2011.09.24 12:26:21 2011.01.02 19:09 Agent86_5min EURUSD,M5: v3[5]= 1.3361 if
2011.09.24 12:26:21 2011.01.02 19:09 Agent86_5min EURUSD,M5: v3[6]= 1.3343 else
2011.09.24 12:26:21 2011.01.02 19:09 Agent86_5min EURUSD,M5: v3[7]= 1.3343 else
2011.09.24 12:26:21 2011.01.02 19:09 Agent86_5min EURUSD,M5: v3[8]= 1.3343 else
2011.09.24 12:26:21 2011.01.02 19:09 Agent86_5min EURUSD,M5: v3[9]= 1.3343 else
2011.09.24 12:26:21 2011.01.02 19:09 Agent86_5min EURUSD,M5: v3[10]= 1.3343 if
2011.09.24 12:26:21 2011.01.02 19:09 Agent86_5min EURUSD,M5: v3[11]= 1.3399 else


Thanks again
 
I suspect that you really don't want or need the else
 
RaptorUK:
I suspect that you really don't want or need the else

Yep your right

Reason: