Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Global Draw Object

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

    Global Draw Object

    Is there a way to make a draw object (for example an Arrow) for an indicator appear on all chart, on multiple instrument? In other words, the draw object on Nasdaq -NQ will also appear on S&P 500 - ES chart.

    #2
    Hello cryfgg,

    Thanks for your post.

    We do not offer any support for global drawing objects on multiple instruments.

    The closest you can get would be to add a public method to your indicator that takes a start time and end time, and a start and end price. The method could then use those parameters to call Draw.ArrowLine() with a specific tag to update that arrow line, or draw a new one.

    The indicator then would need to be added to all charts that where the arrow line should be draw.

    Then, when the indicator should call Draw.ArrowLine(), do this instead: loop through all windows, and within all windows that are charts, loop through the active ChartControl Indicators collection and find your indicator, then call the indicator's public method and give it the start/end price/time parameters. (I would only attempt to modify things on other windows after State == State.Realtime)

    Here is some code to loop through windows and loop through indicators in the ActiveChartControl Indicators collection.

    Code:
        foreach (var window in NinjaTrader.Core.Globals.AllWindows)
        {
            // check if the found window is a Chart window, if not continue looking
            if (!(window is NinjaTrader.Gui.Chart.Chart)) continue;
    
            window.Dispatcher.InvokeAsync(new Action(() =>
            {
                // try to cast as a Chart, if it fails it will be null
                var foundChart = window as NinjaTrader.Gui.Chart.Chart;
    
                // make sure we found a chart
                if (foundChart == null) return;
    
                // make sure the found chart is the owner window
                if (foundChart != this.Owner as NinjaTrader.Gui.Chart.Chart) return;
    
                // Instantiate indicator collection
                ChartObjectCollection<NinjaTrader.Gui.NinjaScript. IndicatorRenderBase>  indicatorCollection = foundChart.ActiveChartControl.Indicators;
    
                 // Loop through indicators in collection
                 foreach (Indicator indi in indicatorCollection)
                      Print(indi.Name);
    
             }));
    
         }
    Draw.ArrowLine() - https://ninjatrader.com/support/help..._arrowline.htm
    ChartControl.Indicators - https://ninjatrader.com/support/help...indicators.htm

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by slimcactus, Today, 10:26 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Monares, Today, 10:49 AM
    3 responses
    17 views
    0 likes
    Last Post NinjaTrader_JustinD  
    Started by d122y, Today, 10:20 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by trader3000a, Today, 06:41 AM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by trader3000a, Today, 09:23 AM
    5 responses
    20 views
    0 likes
    Last Post trader3000a  
    Working...
    X