How to access Close array in C++ DLL?

Hi,
I am new to the Amibroker AFL. I have a AFL and want to create Plugin in C++.
I went through the ADK provided and know the basic idea behind it.

In my AFL code, I am accessing the Close array - KeyPrice = LastValue(C);

I know how to call the LastValue function from C++ code but How I will get the Close price array 'C' in C++ code?
Please give some hints. Thank you.

You should not "go through" the ADK but read it carefully and slowly instead. It is not much text but every sentence is important. Once you read it carefully and slowly, you will know how to access Close array (it is in the docs and in the sample code).

Also if you are new to AFL, you certainly should not create DLL plugins at this time. DLLs are NOT needed for anything except interfacing with things like external data sources and binary APIs.

1 Like

This is such a nice information. It really works for me.

You should read the document in ADK. Read carefully you will know and can do it. After read two times now I can create AFL Plugins. I hope you can do it well.

1 Like

Hi,
I am using this way. I am getting the open value on the chart but looks it is giving wrong value -
AmiVar arg1[ 3 ];

 struct StockArrays sa;
 GetStockArrays( &sa );
	
  char openarr[50];
   float open = *(sa.Open);    
   ftoa(open, openarr, 2);  //converts float to string
   arg1[0].type=VAR_STRING;
   arg1[0].string=strcat(openarr,":DLL Open");


arg1[ 1 ].type = VAR_FLOAT;
arg1[ 1 ].val = 650;
 arg1[ 2 ].type = VAR_FLOAT;
arg1[ 2 ].val = 250;

AmiVar result = gSite.CallFunction( "GfxTextOut", 3, arg1 );

Please ler me know what mistake i am making?

sa.Open is an C array. You should read basics about arrays in C, see: https://www.programiz.com/c-programming/c-arrays and then you will know how to access array elements. Using plain pointer gives you just first array item, not the last.

Hi,
Thanks for your Help.
I tried this and it worked -

struct StockArrays sa;
GetStockArrays( &sa );
float lastopen;
int opensize=sa.Size;

   lastopen=sa.Open[opensize-1];

Open = gSite.GetStockArray(0);
High = gSite.GetStockArray(1);
Low = gSite.GetStockArray(2);
Close = gSite.GetStockArray(3);
Volume = gSite.GetStockArray(4);
OpenInterest = gSite.GetStockArray(5);
Aux1 = gSite.GetStockArray(6);
Aux2 = gSite.GetStockArray(7);

1 Like

Thank you..It worked