Welcome to NexusFi: the best trading community on the planet, with over 200,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
This needs a real programmer to fix. This is a bar type for Delta Bars in Multicharts. From the Custom Resolutions Editor - I was trying to get Delta bars for Multicharts like in Ninja Trader. I'm sure this would be useful for many people if we get it to work.
#define TRACE
using System;
using System.Runtime.InteropServices;
using CustomResolutionsTypes;
using System.Diagnostics;
namespace DeltaBars
{
[ComVisible(true)]
[Guid("55915203-40eb-40d5-b5da-c826b08e090a")]
[ClassInterface(ClassInterfaceType.None)]
[CustomResolutionPluginAttribute(RuleOHLC = true)]
public class Plugin : ICustomResolutionPlugin, ICustomPluginFormatParams, ICustomResolutionStyles
{
#region Fields
private long m_Volume = 0;
private long m_UpVolume = 0;
private long m_DownVolume = 0;
private double m_PointValue = 0.0001;
private long m_MinMovement = 1;
private long m_TrendDeltaThreshold = 1000; // Threshold for continuing trend
private long m_TrendReversalThreshold = 500; // Threshold for trend reversal
private long m_CumulativeDelta = 0; // Tracks upVolume - downVolume
private long m_PeakDelta = 0; // Tracks highest/lowest delta in current trend
private bool m_IsBullishTrend = true; // Tracks current trend direction
#endregion
#region Ctor
public Plugin()
{
}
#endregion
#region ICustomResolutionPlugin
public string Name
{
get { return "Delta Bars"; }
}
public string Guid
{
get { return "2df36d33-92f6-4549-953e-30fa3de4efaf"; }
}
public string Description
{
get { return "Bars based on cumulative delta with trend continuation and reversal thresholds."; }
}
public string Vendor
{
get { return "PainlessTrader"; }
}
public void Init(IBaseOptions baseOptions, IParams customParams)
{
if (baseOptions != null)
{
m_PointValue = baseOptions.PointValue;
m_MinMovement = baseOptions.MinMovement;
}
// Safely retrieve parameters from IParams
try
{
if (customParams != null)
{
// Attempt to access parameters by name
// Replace 'GetParamByName' with the actual method if different (check MultiCharts SDK)
object trendDeltaValue = customParams.GetParamByName?.Invoke("Trend Delta")?.Value;
object trendReversalValue = customParams.GetParamByName?.Invoke("Trend Reversal")?.Value;
if (trendDeltaValue != null)
{
m_TrendDeltaThreshold = Convert.ToInt64(trendDeltaValue);
}
if (trendReversalValue != null)
{
m_TrendReversalThreshold = Convert.ToInt64(trendReversalValue);
}
}
}
catch (Exception ex)
{
Trace.TraceError($"Error reading custom parameters: {ex.Message}");
// Keep default values if parameters are invalid
}
The foundation here is solid - you have the right interfaces implemented and the delta accumulation logic makes sense. A few things to check:
1. Parameter Access Issue
The syntax for accessing custom parameters looks incorrect:
The IParams interface in MultiCharts SDK typically uses a different accessor pattern. Check the pre-built custom resolution plugins that ship with MultiCharts (Range Bars, Renko, etc.) - they show the correct way to retrieve parameter values. These templates are in your MultiCharts installation folder under the Custom Resolutions samples.
2. Missing Parameter Definition Interface
To expose "Trend Delta" and "Trend Reversal" in the Custom Resolutions Manager UI, you likely need to implement an additional interface that defines these parameters. The pre-built samples show how to register custom parameters so users can modify them.
3. Your Logic Looks Sound
The approach of tracking cumulative delta (upVolume - downVolume) and closing bars when thresholds are crossed is correct. The trend continuation vs reversal threshold distinction is a nice touch.
Next Steps
Open one of the working pre-built plugins in Visual Studio and compare the Init() method
Check how they access IParams - this is likely where the issue lives
Add debug output to confirm your code is being called at all
If you post the specific error messages from the Output Window when loading the plugin, that would help narrow down the issue.
-- Fi "The best debugging starts with the simplest working example."
Please leave feedback here. You can disable my ability to reply to your posts by placing me on your ignore list.
Fi provides educational information on a best-effort basis only. You are responsible for your own trading decisions and for verification of all data. This message is not trading advice.