Study Plugin Template
May 14, 2026 · View on GitHub
A working scaffold for a VisualHFT study (analytic / indicator) plugin.
Compiles against the current VisualHFT.Commons API out of the box — clone,
fill in the TODOs with your calculation, build, and the main app will pick
it up.
For a deeper walkthrough see StudySDK_Guidelines.md.
Layout
SDK-StudyTemplate/
├── TemplateStudyPlugin.cs # Plugin class (extends BasePluginStudy)
├── Study.Template.csproj # .NET 10 / WPF class library
├── Model/PlugInSettings.cs # Persisted settings (implements ISetting)
├── ViewModels/
│ ├── PluginSettingsViewModel.cs # Settings UI ViewModel
│ └── TemplateStudyViewModel.cs # Optional: custom visualization VM
├── UserControls/
│ ├── PluginSettingsView.xaml(.cs) # Settings UI
│ └── TemplateStudyView.xaml(.cs) # Optional: custom visualization UI
└── StudySDK_Guidelines.md
The scaffold gives you the BasePluginStudy overrides, an
HelperOrderBook.Instance subscription, a non-blocking HelperCustomQueue
for processing snapshots off the data-feed thread, an onDataAggregation
hook, alert wiring via OnAlertTriggered, and a complete MVVM settings UI.
How a study plugin works
BasePluginStudy provides the plumbing; you provide the math.
- The framework calls
LoadSettings()on startup; you populate_settings. StartAsync()subscribes toHelperOrderBook.Instance(orHelperTrade.Instance, etc.) and enqueues snapshots onto aHelperCustomQueue<T>so the calculation runs off the data-feed thread.- Inside your queue handler, compute a value and publish it by calling
AddCalculation(new BaseStudyModel { Value = ..., Timestamp = ..., MarketMidPrice = ... }). Do not raiseOnCalculatedyourself —AddCalculationdoes that for you and applies any aggregation configured in_settings.AggregationLevel. - Override
onDataAggregation(...)to control how successive values are merged when aggregation is enabled (e.g. last-value-wins, sum, average). - Fire
OnAlertTriggered?.Invoke(this, value)when an alert condition is met.
Build your study
- Copy this folder next to the other studies:
VisualHFT.Plugins/Studies.<YourStudy>/. - Rename the project, namespace, and
TemplateStudyPluginclass to match your study (e.g.Studies.MyIndicator/MyIndicatorStudy). - Update
Name,Version,Description,Author,TileTitle, andTileToolTipin the plugin class — these surface in VisualHFT's UI. - Edit
PlugInSettings.csto add your study's parameters (lookback period, thresholds, smoothing flags, etc.) and remove theCustomParameter1/CustomParameter2placeholders. - Fill in
QUEUE_onRead(OrderBookSnapshot)with your calculation. Alwayssnapshot.Dispose()at the end so its pooled arrays are returned. - Adjust
onDataAggregationif your study needs anything other than last-value-wins aggregation. - Update the settings UI —
PluginSettingsView.xamlplus its ViewModel — to surface your new parameters.
Publishing a value looks like this:
private void QUEUE_onRead(OrderBookSnapshot snapshot)
{
if (snapshot.Bids.Length == 0 || snapshot.Asks.Length == 0)
{
snapshot.Dispose();
return;
}
double value = YourCalculation(snapshot);
AddCalculation(new BaseStudyModel
{
Value = (decimal)value,
Timestamp = HelperTimeProvider.Now,
MarketMidPrice = (decimal)((snapshot.Asks[0].Price + snapshot.Bids[0].Price) / 2.0)
});
if (value > _settings.AlertThreshold)
OnAlertTriggered?.Invoke(this, (decimal)value);
snapshot.Dispose();
}
BaseStudyModel only carries Value, Timestamp, MarketMidPrice (and a
few flags). The symbol and provider come from _settings, not the model.
Load it into VisualHFT
At runtime, VisualHFT.PluginManager.PluginManager.LoadPlugins() scans the
app's base directory for any *.dll that exposes a non-abstract type
implementing IPlugin and instantiates it. There is no separate plugins
folder — the DLL just needs to land next to VisualHFT.exe.
The canonical way to get it there is to add a ProjectReference to the main
app's VisualHFT.csproj:
<ProjectReference Include="VisualHFT.Plugins\Studies.MyIndicator\Studies.MyIndicator.csproj" />
(See VisualHFT.csproj for the existing entries — LOBImbalance,
MarketResilience, VPIN, OTT_Ratio.) Rebuild the solution and your study
appears in VisualHFT's study list and can be added to any dashboard. No
manual DLL copying, no registration step.
Reference implementations
When in doubt, copy the closest match:
VisualHFT.Plugins/Studies.LOBImbalance/— the simplest study, ratio computed per order-book update.VisualHFT.Plugins/Studies.VPIN/— windowed statistical aggregation.VisualHFT.Plugins/Studies.MarketResilience/— multi-feed study with custom visualization.