How to AutoRefresh for plugin?

I am creating a Data Plugin DLL according to the instructions as in the Data_Template example of http://www.amibroker.com/bin/ADK.zip

With GetQuotesEx() function like this

PLUGINAPI int GetQuotesEx( LPCTSTR pszTicker, int nPeriodicity, int nLastValid, int nSize, struct Quotation *pQuotes, GQEContext *pContext  )
{

	// we assume that intraday data files are stored in ASCII subfolder
	// of AmiBroker directory and they have name of .AQI
	// and the format of Date(YYMMDD),Time(HHMM),Open,High,Low,Close,Volume
	// and quotes are sorted in ascending order - oldest quote is on the top

	char filename[ 256 ];
	FILE *fh;
	int  iLines = 0;
	
	// format path to the file (we are using relative path)
	sprintf( filename, "ASCII\\%s.csv", pszTicker );

	// open file for reading
	fh = fopen( filename, "r" );

	// if file is successfully opened read it and fill quotation array
	if( fh )
	{
		char line[ 256 ];

		// read the line of text until the end of text
		// but not more than array size provided by AmiBroker
		while( fgets( line, sizeof( line ), fh ) && iLines < nSize )
		{
			// get array entry
			struct Quotation *qt = &pQuotes[ iLines ];
			
			// parse line contents: divide tokens separated by comma (strtok) and interpret values
			
			// date	and time first
			int datenum = atoi( strtok( line, "," ) );	// YYMMDD
			int timenum = atoi( strtok( NULL, "," ) );	// HHMM

			// unpack datenum and timenum and store date/time 
			qt->DateTime.Date = 0; // make sure that date structure is intialized with zero
			qt->DateTime.PackDate.Minute = timenum % 100;
			qt->DateTime.PackDate.Hour = timenum / 100;
			qt->DateTime.PackDate.Year = 2000 + datenum / 10000;
			qt->DateTime.PackDate.Month = ( datenum / 100 ) % 100;
			qt->DateTime.PackDate.Day = datenum % 100;

			// now OHLC price fields
			qt->Open = (float) atof( strtok( NULL, "," ) );
			qt->High = (float) atof( strtok( NULL, "," ) );
			qt->Low  = (float) atof( strtok( NULL, "," ) );
			qt->Price = (float) atof( strtok( NULL, "," ) ); // close price

			// ... and Volume
			qt->Volume = (float) atof( strtok( NULL, ",\n" ) );

			iLines++;
		}

		// close the file once we are done
		fclose( fh );

	}

	// return number of lines read which is equal to
	// number of quotes
	return iLines;	 
}

The plugin active but there is no automatic Refresh to get the new Data in the * .csv file.

Please teach me, how to AutoRefresh for plugin.

Thank you!

Hi @diamond,

Please see this post:

https://forum.amibroker.com/t/disable-or-programmatically-flush-in-memory-cache/3077

2 Likes

This thread is a duplicate and exact answer solution is given in existing thread: