Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Global Drawing with Labels

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Global Drawing with Labels

    Hi,
    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?






    ​​
    Code:
    [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);
    }
    ​
    Attached Files

    #2
    Hello carlosgutierrez,

    It is not clear from only the images what the problem is, what specifically are you seeing happen differently between the charts?

    Comment


      #3
      hey Jesse, I'd like to bee the same style and lables accross charts. Like when you manually select to share the drawing "All Charts" in the object property.

      the indicator draws some price levels on the base/source chart, then a boolean in the chart trader enables/disables the "global drawings". Currently, when bool = true = is global true, the current obejcts (draw.ray and labels) are sent to other charts as different object.

      how can I get the same drawing all accross?

      Comment


        #4
        Hello carlosgutierrez,

        To draw a global object from code you would have to use the overload for the tool that has isGlobal. For example a dot:

        Draw.Dot(NinjaScriptBase owner, string tag, bool isAutoScale, DateTime time, double y, bool isGlobal, string templateName)

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        127 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        72 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        112 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        109 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        88 views
        0 likes
        Last Post CarlTrading  
        Working...
        X