Complete guide for building the OpenAlgo AmiBroker Plugin from source.
- Prerequisites
- Environment Setup
- Building the Plugin
- Testing
- Deployment
- Troubleshooting Build Issues
- Development Workflow
- Version: Visual Studio 2019 or later (2022 recommended)
- Edition: Community, Professional, or Enterprise
- Workloads Required:
- Desktop development with C++
- Windows 10/11 SDK
- C++ MFC for latest build tools (x86 & x64)
- Version: Windows 10 SDK (10.0.19041.0) or later
- Automatically installed with Visual Studio C++ workload
- Location: Included in
ADKfolder - Files:
Plugin.h,Plugin_Legacy.h - No separate installation needed
- Git: For version control
- GitHub Desktop: For easier Git operations
- VS Code: For quick edits and documentation
- WinMerge or Beyond Compare: For comparing code changes
git clone https://github.com/marketcalls/OpenAlgo-Amibroker-Plugin.git
cd OpenAlgo-Amibroker-Plugin/OpenAlgoPlugin- Launch Visual Studio
- Open
OpenAlgoPlugin.sln - Wait for solution to load and restore NuGet packages (if any)
Check these settings in Visual Studio:
Project Properties → General
- Configuration Type: Dynamic Library (.dll)
- Target Name: OpenAlgo
- Platform Toolset: Visual Studio 2019 (v142) or later
- Windows SDK Version: 10.0 (latest installed)
- Character Set: Use Unicode
Project Properties → C/C++ → General
- Additional Include Directories:
$(ProjectDir)$(ProjectDir)ADK\Include
Project Properties → C/C++ → Precompiled Headers
- Precompiled Header: Use (/Yu)
- Precompiled Header File: StdAfx.h
Project Properties → Linker → General
- Additional Library Directories:
$(ProjectDir)ADK\Lib
1. Select "Debug" configuration from toolbar
2. Select "x64" platform
3. Press F7 or Build → Build Solution
Output: x64\Debug\OpenAlgo.dll
1. Select "Release" configuration from toolbar
2. Select "x64" platform
3. Press F7 or Build → Build Solution
Output: x64\Release\OpenAlgo.dll
- Purpose: Development and debugging
- Optimizations: Disabled (/Od)
- Debug Info: Full (/Zi)
- Runtime Library: Multi-threaded Debug DLL (/MDd)
- Size: Larger (~2-3 MB)
- Performance: Slower
Use Debug build when:
- Developing new features
- Debugging issues
- Testing changes
- Learning codebase
- Purpose: Production deployment
- Optimizations: Maximum (/O2)
- Debug Info: None or minimal
- Runtime Library: Multi-threaded DLL (/MD)
- Size: Smaller (~500 KB)
- Performance: Optimal
Use Release build when:
- Creating distributable version
- Performance testing
- Final testing before release
- Deploying to users
Open Developer Command Prompt for VS 2019 (or later):
cd C:\Users\Admin1\source\repos\OpenAlgoPlugin\OpenAlgoPlugin
msbuild OpenAlgoPlugin.sln /p:Configuration=Release /p:Platform=x64"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" ^
OpenAlgoPlugin.sln ^
/p:Configuration=Release ^
/p:Platform=x64 ^
/mParameters:
/p:Configuration=Release- Build in Release mode/p:Platform=x64- Target 64-bit platform/m- Use multiple CPU cores
To build both Debug and Release:
msbuild OpenAlgoPlugin.sln /p:Configuration=Debug /p:Platform=x64
msbuild OpenAlgoPlugin.sln /p:Configuration=Release /p:Platform=x64Currently, unit tests are minimal. To add tests:
- Create a test project (Google Test or CTest)
- Add test cases for critical functions
- Run tests before committing changes
-
Copy DLL to AmiBroker:
copy /Y "x64\Release\OpenAlgo.dll" "C:\Program Files\AmiBroker\Plugins\"
-
Restart AmiBroker
-
Open Configuration:
- File → Database Settings → Configure
- Verify plugin appears in list
-
Test Connection:
- Enter server details
- Click "Test Connection"
- Click "Test WebSocket"
- Both should show success
-
Test Historical Data:
- Add a symbol (e.g., RELIANCE-NSE)
- Verify chart loads with data
- Check for any errors in AmiBroker log
-
Test Real-time Data:
- Open quote window
- Verify LTP updates
- Check status LED color
- Build Debug configuration
- Copy DLL to AmiBroker Plugins folder
- In Visual Studio: Debug → Attach to Process
- Select
Broker.exe(AmiBroker) - Click Attach
- Set breakpoints in plugin code
- Trigger plugin functionality in AmiBroker
Add debug logging:
#ifdef _DEBUG
OutputDebugString(_T("Debug message here\n"));
#endifView output in Visual Studio Output window or use DebugView.
msbuild OpenAlgoPlugin.sln /p:Configuration=Release /p:Platform=x64Create deployment folder structure:
OpenAlgo-Plugin-v1.0.0/
├── OpenAlgo.dll (from x64\Release\)
├── README.md (user guide)
├── LICENSE (license file)
└── docs/
├── INSTALLATION.md
└── TROUBLESHOOTING.md
cd x64\Release
powershell Compress-Archive -Path OpenAlgo.dll,README.md,LICENSE -DestinationPath OpenAlgo-Plugin-v1.0.0.zip- Extract ZIP to clean folder
- Copy DLL to fresh AmiBroker installation
- Test all functionality
- Verify no errors or missing dependencies
Follow Semantic Versioning:
- MAJOR.MINOR.PATCH (e.g., 1.2.3)
- Increment MAJOR for breaking changes
- Increment MINOR for new features
- Increment PATCH for bug fixes
Edit Plugin.cpp:
#define PLUGIN_VERSION 10003 // Version 1.0.3Format: MAJOR*10000 + MINOR*100 + PATCH
- Tag version:
git tag v1.0.3 - Push tag:
git push origin v1.0.3 - Create Release on GitHub
- Upload ZIP file
- Write release notes (see CHANGELOG.md)
Cause: MFC libraries not installed
Solution:
- Open Visual Studio Installer
- Modify installation
- Check "C++ MFC for latest build tools"
- Click Modify and wait for installation
Cause: Missing library or incorrect linker settings
Solution:
- Check Linker → Input → Additional Dependencies
- Verify all required libraries are listed:
ws2_32.lib(WinSock)wininet.lib(WinInet)
- Clean and rebuild solution
Cause: MFC resources not found
Solution:
- Verify MFC is installed
- Check Include Directories contains SDK paths
- Rebuild solution
Cause: Debug symbols not found (warning, not critical)
Solution:
- This is a warning, can be ignored
- Or download symbols from Microsoft Symbol Server
- Or disable symbol loading for system DLLs
If build is corrupted:
# Delete all build artifacts
rmdir /S /Q x64
rmdir /S /Q .vs
# Rebuild solution
msbuild OpenAlgoPlugin.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64In Visual Studio:
- Build → Clean Solution
- Build → Rebuild Solution
# Create feature branch
git checkout -b feature/new-feature
# Make changes and commit
git add .
git commit -m "Add new feature"
# Push to GitHub
git push origin feature/new-feature
# Create Pull Request on GitHub- Build succeeds in both Debug and Release
- No compiler warnings
- Code is formatted consistently
- Comments added for complex logic
- Tested in AmiBroker
- Documentation updated if needed
Use clear, descriptive commit messages:
<type>: <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting)refactor: Code refactoringtest: Adding testschore: Build or tooling changes
Example:
fix: Normalize timestamps for 1-minute bars
- Added timestamp normalization in Plugin.cpp:708-717
- Prevents freak candles during live updates
- Matches approach used for daily bars
Fixes #42
// Classes: PascalCase
class ConfigDialog { };
// Functions: PascalCase
void GetHistoricalData();
// Variables: camelCase
int quoteIndex = 0;
// Global variables: g_ prefix
CString g_oApiKey;
// Constants: UPPER_CASE
#define MAX_BUFFER_SIZE 4096
// Member variables: m_ prefix
CString m_sServerUrl;- Indentation: Tabs (4 spaces)
- Braces: K&R style (opening brace on same line)
- Line length: Max 120 characters
- Comments: Use // for single-line, /* */ for multi-line
// Good: Clear function with proper formatting
void ProcessQuoteData(const CString& symbol, float price)
{
if (price > 0)
{
// Update cache with new price
UpdateQuoteCache(symbol, price);
}
else
{
// Log error for invalid price
LogError(_T("Invalid price received"));
}
}- Plan: Write design document
- Branch: Create feature branch
- Implement: Write code with comments
- Test: Test in Debug mode
- Review: Self-review code
- Document: Update documentation
- Build: Build Release version
- Test: Test Release build
- Commit: Commit with clear message
- PR: Create Pull Request
Create .github/workflows/build.yml:
name: Build Plugin
on: [push, pull_request]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1
- name: Build
run: msbuild OpenAlgoPlugin.sln /p:Configuration=Release /p:Platform=x64
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: OpenAlgo.dll
path: x64/Release/OpenAlgo.dll- GitHub Issues: Bug reports and feature requests
- OpenAlgo Forum: General discussion
- Discord: Real-time chat
Happy Building! If you encounter issues not covered here, please open an issue on GitHub.