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."
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by gentlebenthebear, Today, 01:30 AM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by PhillT, Today, 02:16 PM
            2 responses
            6 views
            0 likes
            Last Post PhillT
            by PhillT
             
            Started by Kaledus, Today, 01:29 PM
            3 responses
            10 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by frankthearm, Yesterday, 09:08 AM
            14 responses
            47 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by PaulMohn, Today, 12:36 PM
            2 responses
            17 views
            0 likes
            Last Post PaulMohn  
            Working...
            X