Top | Amibroker Data Plugin Source Code
The Quotation structure represents a single data point (a bar or a tick) in the time-series array.
__declspec(dllexport) int GetQuotesEx(char *Ticker, int Period, int Format, int NRows, struct Quotation *Quotes, struct RecentInfo *RecentInfo) // NRows represents the maximum array space allocated by AmiBroker. // 'Quotes' points to the array buffer that needs to be filled. int internalDataCount = FetchDataFromCustomSource(Ticker, Period); int rowsToFill = (internalDataCount > NRows) ? NRows : internalDataCount; for(int i = 0; i < rowsToFill; i++) // Example Mapping Framework Quotes[i].DateTime = GetTimestampAtIndex(i); Quotes[i].Open = GetOpenPriceAtIndex(i); Quotes[i].High = GetHighPriceAtIndex(i); Quotes[i].Low = GetLowPriceAtIndex(i); Quotes[i].Price = GetClosePriceAtIndex(i); // 'Price' is treated as Close Quotes[i].Volume = GetVolumeAtIndex(i); Quotes[i].OpenInterest = 0; // Return the total number of rows successfully populated in the array return rowsToFill; Use code with caution. 5. Transitioning to Real-Time Data Streaming amibroker data plugin source code top
Because AmiBroker is a 32-bit or 64-bit multi-threaded application, thread safety is paramount. Developers must use mutexes or critical sections when accessing shared data structures to prevent crashes. Furthermore, memory management must be impeccable; leaking memory in a data plugin will eventually lead to system instability, especially during long trading sessions where millions of ticks may be processed. The Quotation structure represents a single data point
Below is a foundational, clean implementation of a standard AmiBroker data plugin written in C++. This template handles the basic handshake and establishes the structures required to return data bars. memory management must be impeccable
class MyDataPlugin : public CAbDataPlugin
Amibroker uses a set of data structures to represent financial data, including: