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

Custom Indicator Visibility

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

    Custom Indicator Visibility

    Hello. I am messing around with the ChartCustomSidePanelExample. I have done an extensive search on all existing forums. I have placed a button in the panel and want to have a custom indicator named MyCustomIndicator's visibility be toggled on and off just like you can do manually on any indicator via the Indicator Properties Visible checkbox. The whole indicator becomes invisible with this UI procedure. Our indicator has some Draw.Regions (from Series<double>), Draw.Text (from Series<string>) and plots from Series<double>. When I click the button only the Series<double> plots are turned off, the other objects of the indicator stay visible such as the Regions and Text. I use the same code to populate the list box and the output window. The regions don't show up in the list box but they do in the output and I am not even sure where the Rays are coming from. I am filtering out the Text strings in the list box and output window as there are a lot. But you can still see the Draw.Text above each bar as well as the Draw.Regions that should be off. The Series<double> plots are off in the attached picture. Below is the sample code. Thank you for your assistance.

    Tom

    Code:
    protected void Button2_Click(object sender, RoutedEventArgs e)
    {
    foreach (var myObj in chartWindow.ActiveChartControl.ChartObjects)
    {
    if (myObj != null)
    {
    if (myObj.Name != "Text") Print("ChartObjects = " + myObj.Name);
    if (myObj.Name == "MyCustomIndicator")
    {
    if (showIndicator)
    {
    myObj.IsVisible = false;
    Print("Hide Indicator");
    }
    else if (!showIndicator)
    {
    myObj.IsVisible = true;
    Print("Show Indicator");
    }
    showIndicator = !showIndicator;
    }
    }
    }
    
    if(button2.Content == "Hide")
    {
    button2.Content = "Show";
    }
    else
    {
    button2.Content = "Hide";
    }
    }
    Click image for larger version

Name:	capture.png
Views:	756
Size:	99.5 KB
ID:	1150865
    Intelligent Trader Inc.
    NinjaTrader Ecosystem Vendor - Artificial Intelligence Based Indicators

    #2
    Hello intelligenttrader,

    I would recommend having a look at the updated version of this script SampleWPFModifications.
    https://ninjatrader.com/support/foru...07#post1124507

    The button should causing the wpf objects to be removed from the chartGrid.Children, the column removed from the grid, and the remaining items shifted over. In SampleWPFModifications this is demonstrated on lines 692 to 700.

    It appears the unsupported code you have, attempts to hide an entire indicator and it's plots, but does not attempt to change the WPF.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea and thanks for the update modifications. I am trying to toggle the visibility of the MyCustomIndicator via the button in the MyCustomPanel indicator. I don't want to remove the controls from the panel as lines 692 to 700 do. What ways can you suggest for visibility of the entire indicator as once.
      Intelligent Trader Inc.
      NinjaTrader Ecosystem Vendor - Artificial Intelligence Based Indicators

      Comment


        #4
        Hello intelligenttrader,

        There are no methods made by NinjaTrader to modify WPF in NinjaScript.

        Any changes to WPF made by script, will also have to be changed back by the same script.

        If you are wanting to hide plots, the IsVisible property can be set to false.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I just want to make the indicator invisible on the chart. I don't want to remove it from the chart. I can do it manually by going into the properties dialog and unchecking Visible. See the EMA example. In the image visible.png I have loaded the EMA. In invisible.png I have uncheck the Visible checkbox and the indicator is now invisible. Are you saying I can't programmatically go through a collection of indicator objects and make them visible / invisible?

          Click image for larger version

Name:	visible.png
Views:	493
Size:	89.6 KB
ID:	1151120Click image for larger version

Name:	invisible.png
Views:	482
Size:	85.7 KB
ID:	1151121
          Intelligent Trader Inc.
          NinjaTrader Ecosystem Vendor - Artificial Intelligence Based Indicators

          Comment


            #6
            Hello intelligenttrader,

            The indicator's IsVisible affects things rendered in the RenderTarget of the chart, such as plots, lines, and drawing objects. This would not affect WPF such as buttons, checkboxes, etc.

            But yes, you can set the IsVisible from within a script to hide plots and drawing objects.

            Looping through the indicators on a chart is possible, but is undocumented and not officially supported.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by dustydbayer, Today, 01:59 AM
            0 responses
            1 view
            0 likes
            Last Post dustydbayer  
            Started by inanazsocial, Today, 01:15 AM
            0 responses
            2 views
            0 likes
            Last Post inanazsocial  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            5 responses
            22 views
            0 likes
            Last Post trilliantrader  
            Started by Davidtowleii, Today, 12:15 AM
            0 responses
            3 views
            0 likes
            Last Post Davidtowleii  
            Started by guillembm, Yesterday, 11:25 AM
            2 responses
            10 views
            0 likes
            Last Post guillembm  
            Working...
            X