Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

One indicator change the properties of another Indicator

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

    One indicator change the properties of another Indicator

    Is it possible for one indicator to change the properties of another indicator? Essentially I want to create Buttons on the chart that enable me to toggle on and off another indicators visible property.

    #2
    Hello cutzpr,

    This should be possible to do.

    You will need to grab the chart and list the indicators and then find a property to set using undocumented code.

    An example of this is attached.

    This example uses undocumented code and is not officially supported by NinjaTrader Support.
    Attached Files
    Last edited by NinjaTrader_ChelseaB; 05-11-2021, 11:21 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by cutzpr View Post
      Is it possible for one indicator to change the properties of another indicator? Essentially I want to create Buttons on the chart that enable me to toggle on and off another indicators visible property.
      Hello cutzpr,

      I have made an Addon from Jesse's original Addon to set IsVisible true/false.

      Some superfluous code have not been removed and is provided 'as-is'.

      I have actually learned a lot from this particular example, so thanks for posting.

      I have a question for the NT team: Is it possible to add a code snippet to refresh the chart when the 'IsVisible' button is clicked.

      I tried:

      Code:
                  selectedIndicator.OwnerChartControl.InvalidateVisual();
      However, it produced an exception.

      Chelsea, is it actually possible to have access to more code examples, especially interaction between xaml and C#?

      Any code examples like this are priceless.

      Thank you.
      Attached Files

      Comment


        #4
        Hello Sim22,

        Our code examples are written as we get inquiries and need an example to demonstrate.

        NinjaTrader 8 Beta is fairly new and at this time there are not many samples written by support. However the samples written are posted publicly to the forum and I would recommend searching the forum for posts along the interested topic.

        It is possible to trigger a chart to invalidate from an addon using the chart control.

        Code:
        foreach (Window window in Globals.AllWindows)
        {
        	NTWindow w = (NTWindow)window;
        	window.Dispatcher.BeginInvoke(new Action(() =>
        	{
        		if (!w.Caption.Contains("Chart"))
        			return;
        
        		TabControl tc = w.FindFirst("ChartWindowTabControl") as TabControl;
        		if (tc == null)
        			return;
        
        		foreach (TabItem ti in tc.Items)
        		{
        			ChartControl tabChartControl = (ti.Content as ChartTab).ChartControl;
        			if (ti.IsSelected)
        				tabChartControl.InvalidateVisual();						
        		}
        	}));
        }
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you Chelsea

          I understand, however often forum members do not tag threads properly which makes searching very time consuming.

          I know your resources are strapped for time esp. since, as you say, NT8 is still fairly new. I just thought a general depository would be good where useful code could be dumped for reuse. I think it would save you guys/gals time in the long run from answering fragmented questions and save us hours from attempting to piece those fragmented snippets together

          Thanks for your help all the same!

          Simon.

          Comment


            #6
            To All,

            Just an update to this thread.

            The example in Post #2 is using undocumented code and not officially supported by NinjaTrader.

            Further, we advise not invalidating the chart and instead calling ForceRefresh() to prevent deadlocks.

            From the help guide:
            "Warning: Excessive calls to ForceRefresh() and OnRender() can carry an impact on general application performance. You should only call ForceRefresh() if the chart truly needs to be visually updated. It is NOT recommended to invalidate the chart control directly as this could cause issues with threading which result in dead locks."
            https://ninjatrader.com/support/help...rcerefresh.htm
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by 8033075, Yesterday, 08:13 PM
            1 response
            30 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by futurenow, Yesterday, 06:13 PM
            1 response
            21 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by trader3000a, Today, 07:34 AM
            2 responses
            9 views
            0 likes
            Last Post trader3000a  
            Started by focus333, Yesterday, 11:28 PM
            1 response
            22 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by futurenow, Yesterday, 07:03 PM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_Kate  
            Working...
            X