Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
it depends whether or not you need the array outside the function, too. If you do, you would declare it within the calling code and pass the array to the function.
If you only need the array within the function you would declare it within the function.
from your pseudo code it is not clear to me what you are trying to do. Take a look at the array section and the part about "Function Array Parameter Declaration" in the free EasyLanguage Essentials PDF. This should clarify your questions. Apart from that you can also try your ideas with a simple code example.
Here's my intent. I created an array in the strat code that I'll be using within it as well as related functions that I'll be calling. In more than one of the functions, it will be changing the values of the array variables as well as will the strat. So I want the values to be moving around so to speak. So it seems that a) I will need to define the variable as "NumericArrayRef" since the values will go back and forth. My question is...
When calling up the function from within the strategy code, do I simply state it like this...
Value1 = LAYERFUNCTION(Layer);
and will that save all the values of the array variable "Layer" which is 7 items in that array, or do I need the [ ] like this...
Value1 = LAYERFUNCTION(Layer[1], Layer[2], etc);
Please let me know. I can't seem to find it anywhere. Thanks
It seems that the simplest way is this. I read that I am desiring to us an array in an "Input/Output Parameter" so I need to use the input declarations "NumericArrayRef" or "TrueFalseArrayRef" and use [x] to include all elements of the array in declaration even if I only need a few. Also, when calling the function from the strategy, I simply need the name of the array with nothing after it.
So I assume you know how to declare your array in the main strategy - Array: Sample[50](0); I am declaring an array called "Sample" with the size of the array being 50 and the array being numeric with the starting value for each of the 50 items set to zero.
So when I have a function and am writing the function, in the Inputs, I would include Sample[X](NumericArrayRef). Even if I only need the first 5 elements of the array Sample, I still call the whole array. I then write code in that function applicable to that array.
Last, when I'm calling the array in the strategy or anywhere for that matter, you just call the name of the array withing the parameters. For example, for Value1 = FunctionExample(Sample), I am calling on the function called "FunctionExample" that has one input that just happens to be my array called "Sample".