: (Optional) Provides a custom configuration dialog for users to enter API keys or server settings.
Plugin developers also emphasize efficient JSON parsing: packets should be parsed "in-situ" (in memory) for performance. If there is a problem in parsing, all quotes for that packet could be dropped, so this "fail-fast" design is often intentional to maintain stability.
When handling high-frequency intraday data or thousands of concurrent ticker symbols, optimization is crucial. Poorly written plugins can lock up the main AmiBroker user interface thread. Implement Asynchronous Threading
AmiBroker will immediately respond by triggering GetQuotesEx or checking GetRecentInfo to repaint the active charts seamlessly. 5. Memory Management and Best Practices
Excellent starting points include the official ODBC/SQL plugin source code from AmiBroker, the community-developed Rtd_Ws_AB_plugin on GitHub, and the source code included in the AmiBroker Development Kit itself, which contains sample plugins for various tasks. amibroker data plugin source code top
*plugin = new MyDataPlugin(); return S_OK;
#define PLUGIN_NAME "My Data Plugin" #define VENDOR_NAME "My Company" #define THIS_PLUGIN_TYPE PLUGIN_TYPE_DATA
#pragma pack(push, 1) struct Quotation __int64 DateTime; // Packed date/time format float Price; // Close price (or Last price) float Open; float High; float Low; float Volume; float OpenInterest; ; #pragma pack(pop) Use code with caution. Key Considerations for Data Fields
An Amibroker data plugin consists of a DLL (Dynamic Link Library) file that exports a set of functions. These functions are used by Amibroker to interact with the plugin and retrieve data. The plugin architecture is based on the following components: : (Optional) Provides a custom configuration dialog for
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)
Never fetch data on the main AmiBroker thread. If your API call hangs, AmiBroker will freeze. Use a background worker thread to pull data and a thread-safe queue to pass it to the GetQuotes function. 2. Backfill Logic
Protect your real-time data queues using light Synchronization Primitives like CRITICAL_SECTION or std::mutex . Avoid heavy kernel locks that slow down rendering.
You can download the ADK from www.amibroker.com/bin/ADK.zip . The source code is licensed for use in both individual and commercial software, though it is provided "as is" without warranty. When handling high-frequency intraday data or thousands of
Never block the main AmiBroker thread. Use asynchronous sockets to receive data, and buffer the data before sending it to AmiBroker.
PLUGINAPI int Notify( struct PluginNotification *pn ) switch( pn->Reason ) case REASON_DATABASE_LOADED: // Store the workspace and base interval for later use break; case REASON_DATABASE_CREATED: // Initialize database – e.g., retrieve symbol lists break; case REASON_DATABASE_DELETED: // Clean up resources break;
Unlike standard software that constantly queries an external database for every chart refresh, AmiBroker caches data in RAM using a specialized array structure. Your plugin must populate these arrays swiftly to prevent UI freezing. Plugin Types: Streaming vs. On-Demand
C++ header files necessary to interact with the AmiBroker core API. Documentation on plugin architecture.