When you read the Book about Arrays did you see where it said this ?
"When declaring an array, data type, array name and number of elements of each dimension must be specified:"
Yes I did
My understanding was that double v1[] decided the data type globally and before the start() Then [i] initialized the array telling it how many elements are in the array in this case 1 dimension with elements = Bars, however the number changes during deincrementing of i--. right ?
So if it's deincrementing the number of elements then how does the buffer store and post the indicator if the number of elements is no longer there ? Or I guess I should say what happens to the elements as they deincrement [i] ? Do they just disappear ? Are they still stored in v1[i] to be referenced or are they gone ?
If I can figure this out perhaps I may be able to understand how to reference them or if they are gone then I can figure out how to hold them for use. The thing I don't get is the else statement seems to be able to reference v1[i]=v1[i+1] So how can it reference v1[i] if at that point v1[i] = 0 when I print at this point.
This sort of makes sense to = 0 in some sense because if the array is empty then it would print the empty array as 0 since there are no elements in the array.
I'm not sure I really understand it but I keep thinking about it and reading the document it over and over again.
Now considering Bars if Bars has more then 1 number associated with it then the dimension could be different then what I'm thinking. So I guess I'll read up more on that too to be sure I understand what i actually is.
I had though it was just a single number count as in Bar=the number of bars on the chart When I print Bars it give me 1002 on the 5min chart and I am thinking this is a single dimension.
If you want to make an Array bigger (or smaller) you need to use ArrayResize . . . an Array is just like any other variable . . it's just that there can be many of them that you can access easily . . .
Copy this code and run it as a script, what do you think the output will be ?
Interesting I thought the declaration of the number of elements was done with v1[i] ? since i=Bars I thought it was the same as saying v1[Bars] which is whatever that number is
If it's not declared I don't understand how the indicator would know what v1[i] is if I can't reference it either ? This same script works on the indicator version and stores this in the buffer of v1[] so how does it know how to reference the buffer in order to draw the line ?
It's currently working on the indicator. Is this a different subject ?
I'm confused
took out the ending i-- in the first loop oops. but had no effect
With one small change your code seems to do something . . .
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[0]= 0
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[1]= 0
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[2]= 0
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[3]= 0.8202
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[4]= 0.8202
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[5]= 0.8202
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[6]= 0.8202
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[7]= 0.8202
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[8]= 0
"When declaring an array, data type, array name and number of elements of each dimension must be specified:"
With one small change your code seems to do something . . .
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[0]= 0
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[1]= 0
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[2]= 0
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[3]= 0.8202
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[4]= 0.8202
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[5]= 0.8202
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[6]= 0.8202
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[7]= 0.8202
2011.09.21 11:24:41 2007.04.05 21:11 Agent86_5min AUDUSD,H1: v1[8]= 0
"When declaring an array, data type, array name and number of elements of each dimension must be specified:"
My understanding was that double v1[] decided the data type globally and before the start()
Then [i] initialized the array telling it how many elements are in the array in this case 1 dimension with elements = Bars, however the number changes during deincrementing of i--.
right ?
So if it's deincrementing the number of elements then how does the buffer store and post the indicator if the number of elements is no longer there ?
Or I guess I should say what happens to the elements as they deincrement [i] ?
Do they just disappear ? Are they still stored in v1[i] to be referenced or are they gone ?
If I can figure this out perhaps I may be able to understand how to reference them or if they are gone then I can figure out how to hold them for use.
The thing I don't get is the else statement seems to be able to reference v1[i]=v1[i+1] So how can it reference v1[i] if at that point v1[i] = 0 when I print at this point.
This sort of makes sense to = 0 in some sense because if the array is empty then it would print the empty array as 0 since there are no elements in the array.
I'm not sure I really understand it but I keep thinking about it and reading the document it over and over again.
Now considering Bars if Bars has more then 1 number associated with it then the dimension could be different then what I'm thinking.
So I guess I'll read up more on that too to be sure I understand what i actually is.
I had though it was just a single number count as in Bar=the number of bars on the chart
When I print Bars it give me 1002 on the 5min chart and I am thinking this is a single dimension.
I'll keep working on it.
If you want to make an Array bigger (or smaller) you need to use ArrayResize . . . an Array is just like any other variable . . it's just that there can be many of them that you can access easily . . .
Copy this code and run it as a script, what do you think the output will be ?
2011.09.21 07:54:26 none EURUSD,M5: uninit reason 0
2011.09.21 07:54:26 none EURUSD,M5: deinitialized
2011.09.21 07:54:26 none EURUSD,M5: test[39]= 0
2011.09.21 07:54:26 none EURUSD,M5: initialized
This is what the script produces I copied it exactly
I just double clicked it and it ran and this is what appears in the experts tab
The journal of the script just says
2011.09.21 07:54:26 Script none EURUSD,M5: removed
2011.09.21 07:54:26 Script none EURUSD,M5: loaded successfully
I thought I should see 45.6 as the output ? am I wrong ?
I created my own fixed array[5] = {1,2,3,4,5}
And seem to be able to Print[5] or Print[3] etc.
let me put the braces in and see the script again
OK, good . . now edit this line . .
. . . and try again.
2011.09.21 08:07:58 none EURUSD,M5: deinitialized
2011.09.21 08:07:58 none EURUSD,M5: test[39]= 45.6
Darn, got to run out be back in couple hours.
Maybe I can think about this some more while driving
There really isn't anything to think about . . .
"When declaring an array, data type, array name and number of elements of each dimension must be specified:"
You need to declare the number of items in the array . . .
Interesting
I thought the declaration of the number of elements was done with v1[i] ? since i=Bars I thought it was the same as saying v1[Bars] which is whatever that number is
If it's not declared I don't understand how the indicator would know what v1[i] is if I can't reference it either ?This same script works on the indicator version and stores this in the buffer of v1[] so how does it know how to reference the buffer in order to draw the line ?
It's currently working on the indicator. Is this a different subject ?
Yes, Indicator buffers are handled differently to ordinary arrays.
v[i] is not declaring the Array, it's just one of the elements . . but double v[]; is an array with zero elements . . so v[anything] always = 0