I am developing an indicator that plots some levels with a level description on the right side margin.
First image is the source chart levels (magenta and green price levels) and the label.
The red rectangles seen are breached levels.
The Second image is the same source chart with the Global turned to True. the levels change to a generic blue rectangle. I need these to stay consistent as the original (magenta and green)
On the thirdi mage is another chart (same instument "MNQ") with a clean (no indicator) setup, just the Global drawing showing up. This is where I need to see the same structure as the source chart, magenta & green levels and the lables.
I have not been able to translate the drawing correctly.
Any suggestion to making it happen?
[NinjaScriptProperty]
[Display(Name = "Use Global Drawings", Description = "If true, drawings are shared across all charts of the same instrument.", Order = 1, GroupName = "Parameters")]
public bool UseGlobalDrawings { get; set; }
[NinjaScriptProperty]
[Display(Name = "Show Labels", Description = "If true, show right-side labels for POCD levels.", Order = 5, GroupName = "Parameters")]
public bool ShowLabels { get; set; }
private static readonly Color AbovePriceColor = Colors.Magenta;
private static readonly Color BelowPriceColor = Colors.SpringGreen;
private static readonly Color WickTouchColor = Colors.Magenta;
private static readonly DashStyleHelper UntouchedRayDashStyle = DashStyleHelper.Solid;
private static readonly DashStyleHelper WickTouchedRayDashStyle = DashStyleHelper.Dash;
private void GlobalDrawButton_Click(object sender, RoutedEventArgs e)
{
UseGlobalDrawings = !UseGlobalDrawings;
ChartControl?.Dispatcher.InvokeAsync(() =>
{
globalDrawButton.Content = "Global";
global чутьButton.Background = UseGlobalDrawings ? Brushes.SpringGreen : Brushes.Gray;
});
pocLevels.Clear();
SyncLevelsWithGlobal();
ForceRefresh();
}
private void SyncLevelsWithGlobal()
{
if (!UseGlobalDrawings || Instrument == null) return;
string key = Instrument.FullName;
lock (GlobalLevels)
{
if (GlobalLevels.ContainsKey(key))
{
pocLevels = new List<PocLevel>(GlobalLevels[key]);
}
}
}
private string BuildLabelText(PocLevel level)
{
var parts = new List<string>();
parts.Add("");
parts.Add(level.ChartType);
parts.Add($"{level.Price:F2}");
parts.Add($"{level.DisparityRange:F2}");
if (level.IsWickTouched)
{
parts.Add($"Tested: {level.WickTouchCount}");
}
return string.Join(" | ", parts);
}

Comment