View Full Version : Simple code snipet for use of arrays
mpatek
4th September 2010, 04:16 AM
Hello,
I'm trying to write a simple code for returning lowest values from the price array. Need a help with implementing "llv(Close, _days)". Do I need to define array "llv" or is it part of the program? Anyone?
Thanks,
mpatek
David Samborsky
4th September 2010, 05:24 AM
It's available to be applied to an array variable.
Array llv(const Array A,const int N)
See page 124 of the User Guide.
mpatek
4th September 2010, 12:43 PM
Thank Dave,
I am new to C++ and description at p. 124 of the manual has no example of usage. What confuses me is the array declaration different from:
type var-name[size];
Say, for the loaded price chart in MS, the code would be: ??
float llv(const Close, const int N)
{
dprintf("LLV=%f\n",llv(Close,14));
}
It obviously does not work. Could you post a simple example of the full functioning code?
Thanks,
mpatek
David Samborsky
5th September 2010, 12:42 AM
The llv() function is a friend function which acts on an Array object. This is a special data class that I have created in Vitamin-C to handle price arrays. It should not be confused with the typical C array ie float myrray[].
You have to instantiate an Array object or use it with one of the predefined price array objects.
The following example uses the built in llv function to calculate the llv for the average of the opening and closing prices over a 10 bar period. Both Close and the Open are predefined arrays which map directly to the opening and closing price arrays.
void Myllv()
{
Array MyArray;
MyArray=llv((Close + Open)/2,10);
for(int i=MyArray.GetFirstIndex();i<BarCount;i++)
{
dprintf("index=%d, Date=%d, Open Price=%f, Close Price=%f, llv()=%f\n",i,GetDate(i),(double)Open[i],(double)Close[i],(double)MyArray[i]);
}
Result=MyArray;
}
mpatek
5th September 2010, 12:56 AM
Thanks - works OK.
mpatek
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.