For AmiBroker to recognize a DLL as a valid data plugin, the DLL must export a specific set of functions. The primary lifecycle functions include: Function Name Description GetPluginInfo Returns the metadata and capability flags of the plugin. Init
Handles events like database opening, closing, or workspace changes.
To ensure AmiBroker can see your plugin functions, create a module-definition file ( .def ) in your Visual Studio project to prevent C++ name mangling. amibroker data plugin source code top
Below is a structured "paper" or guide on setting up and coding a data plugin from scratch. 1. Getting Started: The AmiBroker Development Kit (ADK)
While Amibroker is closed-source, several top-tier developers have published reference implementations. Searching for typically leads to these archetypes: For AmiBroker to recognize a DLL as a
#include #include #include "Plugin.h" // Header file provided in the AmiBroker ADK // Global instance handle HINSTANCE g_hInst = NULL; // DLL Entry Point BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) switch (ul_reason_for_call) case DLL_PROCESS_ATTACH: g_hInst = (HINSTANCE)hModule; break; case DLL_PROCESS_DETACH: break; return TRUE; // 1. GetPluginInfo: Identifies the plugin to AmiBroker ANALYSISTOOL_API int GetPluginInfo(struct PluginInfo *pInfo) pInfo->StructSize = sizeof(struct PluginInfo); pInfo->Type = PLUGIN_TYPE_DATA; // Defines this as a data plugin pInfo->Version = 10000; // Version 1.0.0 pInfo->ID = CONST_PLUGIN_ID('C', 'U', 'S', 'T'); // Unique 4-byte ID strcpy_s(pInfo->Name, sizeof(pInfo->Name), "Top Custom Data Plugin"); strcpy_s(pInfo->Vendor, sizeof(pInfo->Vendor), "Developer Name"); pInfo->Certificate = 0; // Standard plugin (non-certified) return 1; // 2. Init: Called when AmiBroker loads the plugin ANALYSISTOOL_API int Init(void) // Initialize network libraries, log files, or API clients here return 1; // 3. Release: Called when AmiBroker unloads the plugin ANALYSISTOOL_API int Release(void) // Perform memory cleanup here to prevent leaks return 1; // 4. Notify: Handles state changes within AmiBroker ANALYSISTOOL_API int Notify(struct PluginNotification *pNotif) switch(pNotif->Reason) case NOTIF_DATABASE_LOADED: // AmiBroker opened a database utilizing this plugin break; case NOTIF_DATABASE_UNLOADED: // AmiBroker closed the database break; case NOTIF_TICKER_CHANGED: // User switched to a different symbol chart // pNotif->Ticker contains the new symbol string break; return 1; // 5. GetQuotesEx: Feeds bar data back to AmiBroker ANALYSISTOOL_API int GetQuotesEx(LPCTSTR Ticker, int Period, int nSize, struct QuotationFormat4 *pQuotes, struct RecentInfo *pRecentInfo) // 'Ticker' is the symbol requested (e.g., "AAPL") // 'Period' is the interval (e.g., hourly, daily) // 'nSize' is the maximum number of bars AmiBroker's array can hold // 'pQuotes' is the pointer to the array where data must be written int barsToReturn = 0; // Example logic: Populating a single dummy historical data bar if (nSize > 0 && pQuotes != NULL) // Set the timestamp (AmiBroker packing format) pQuotes[0].DateTime.Packed = 0; // Replace with a valid AmiBroker DateTime bitmask // Populate standard OHLCV fields pQuotes[0].Open = 150.00f; pQuotes[0].High = 155.50f; pQuotes[0].Low = 149.25f; pQuotes[0].Price = 154.00f; // Close price pQuotes[0].Volume = 1200500.0f; pQuotes[0].OpenInterest = 0; barsToReturn = 1; // Set status flags for the user interface if (pRecentInfo != NULL) pRecentInfo->State = 1; // 1 = Connected/Good, 0 = Disconnected // Return the total number of populated bars written to the pQuotes array return barsToReturn; Use code with caution. Optimizing for Top Performance
: This SDK handles multithreading and memory management, which are notoriously difficult in native C++ plugin development. 3. Specialty & Open-Source Projects To ensure AmiBroker can see your plugin functions,
This public link is valid for 7 days and shares a thread, including any personal information you added. This link or copies made by others cannot be deleted. If you share with third parties, their policies apply. Can’t copy the link right now. Try again later.
The ADK provides:
Explain the difference between real-time and historical data handling in the code Help you decide whether to use C++ or C# based on your API