Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

need a idea on adding a panel with texbox on a chart window

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

    need a idea on adding a panel with texbox on a chart window

    i realize that i have a lot of logic that i have setup on my indiccators and often my mind is thinking on which part of the logic is in play. is there a way, i can add a panel with a textbox so i can display running commentary of my rules and which ones are in play.
    if you have used amibroker which has a commentary box. i want to do something like that. i realize that we have only 2 output boxes and so i want to think of a option where i attach a output box to a chart. and be able to write to that output box.

    #2
    Originally posted by junkone View Post
    i realize that i have a lot of logic that i have setup on my indiccators and often my mind is thinking on which part of the logic is in play. is there a way, i can add a panel with a textbox so i can display running commentary of my rules and which ones are in play.
    if you have used amibroker which has a commentary box. i want to do something like that. i realize that we have only 2 output boxes and so i want to think of a option where i attach a output box to a chart. and be able to write to that output box.
    I believe that is what DrawTextFixed() is about. No?

    Comment


      #3
      Not exactly: Let me give an example with the amibroker charting.
      i can write a interpretation for every bar and it will appear on the interpretation window.
      Lets take a simple moving average system and here is what i would love to see
      1. <datetime> crossed over and look for long
      2. <datetime> Pulled back
      3. <datetime> broke out again over previous peak
      4. <datetime> entered long

      ....
      I currently log it in textfile but when i view the chart, they dont stand side by side.
      I would love to integrate it with the chart. its just a textbox that i want to attach to a separate panel or stick it to the side of the chart window. 1 chart + 1 notepad stickie
      Code:
      protected override void OnWindowCreated(Window window)
           {
      		  
      	 }
      it looks like there is a feature to enhance the window object but i dunno how to move forward. a hint or two will help

      Last edited by junkone; 01-27-2016, 08:43 PM.

      Comment


        #4
        I see. That sounds more like a journal, but I am not sure that the NT would suffice, relative to what you describe. For what it is worth,

        ref: http://ninjatrader.com/support/forum...22&postcount=1

        Comment


          #5
          the trade performance is not a useful tool. i want to see the logical decisions that my indicator and strategy is doing in realtime and able to eyeball both the chart and the commentary at same time.
          so the question is "How do we stick a textbox to the chart frame?"

          Comment


            #6
            Originally posted by junkone View Post
            the trade performance is not a useful tool. i want to see the logical decisions that my indicator and strategy is doing in realtime and able to eyeball both the chart and the commentary at same time.
            so the question is "How do we stick a textbox to the chart frame?"
            I had s similar desire, but I eventually moved my focus to displaying the text file.

            Various text-based utility programs can display the running 'tail' of a text file, some are specifically written for this purpose.

            Although old as molasses, I used BareTail on Windows 7:


            I decided that the 'tail' effect was my most important requirement (but I really love the color highlighting of lines) so whether a separate program or the chart itself provided this running tail of the log file was (I realized) not as important.

            What I mean is, consider if your problem can be solved by using a 'tail' utility program that displays the log file in real-time, as the lines are written.

            See attached screenshots of baretail in action (note the color highlighting).
            Attached Files

            Comment


              #7
              i use tail but your implementation is better than mine and i will take some ideas from it. since i trade 5 symbols in 5 charts, i need to keep the tail window next to the chart so i can eyeball at same time.
              Nonetheless, with the power of NT8, there must be a new way of sticking the tail winodow to the chart. I will keep digging and repeat the question.
              "How do we stick a textbox to the chart frame?"

              Originally posted by bltdavid View Post
              I had s similar desire, but I eventually moved my focus to displaying the text file.

              Various text-based utility programs can display the running 'tail' of a text file, some are specifically written for this purpose.

              Although old as molasses, I used BareTail on Windows 7:


              I decided that the 'tail' effect was my most important requirement (but I really love the color highlighting of lines) so whether a separate program or the chart itself provided this running tail of the log file was (I realized) not as important.

              What I mean is, consider if your problem can be solved by using a 'tail' utility program that displays the log file in real-time, as the lines are written.

              See attached screenshots of baretail in action (note the color highlighting).

              Comment


                #8
                Have you taken a look at UserControlCollection? This can be used to add custom elements to chart windows, and you should be able to add a text box from there, dynamically populating it with new info as the script runs.

                Dave I.NinjaTrader Product Management

                Comment


                  #9
                  Originally posted by NinjaTrader_Dave View Post
                  Have you taken a look at UserControlCollection? This can be used to add custom elements to chart windows, and you should be able to add a text box from there, dynamically populating it with new info as the script runs.

                  http://ninjatrader.com/support/helpG...collection.htm
                  definitely, i want to give this a shot. however, would you code this on your indicator code or addon? which template would i start with?

                  Comment


                    #10
                    Either way will work, and it will depend on how persistent you want the text box to be. If you want to place the box on a single chart, from time to time, then an indicator would likely be the best way to go. If you want that text box on all charts at all time, then an AddOn would be best. Keep in mind that AddOn's do not require their own windows at all, but can be used to simply apply UI changes throughout the entire platform.
                    Dave I.NinjaTrader Product Management

                    Comment


                      #11
                      maybe i missed something or dont understand the concept of addons. i cut and paste the code example into the add on template and i am getting errors.

                      Code:
                      #region Using declarations
                      using System;
                      using System.Collections.Generic;
                      using System.ComponentModel;
                      using System.ComponentModel.DataAnnotations;
                      using System.Linq;
                      using System.Text;
                      using System.Threading.Tasks;
                      using System.Windows;
                      using System.Windows.Input;
                      using System.Windows.Media;
                      using System.Xml.Serialization;
                      using NinjaTrader.Cbi;
                      using NinjaTrader.Gui;
                      using NinjaTrader.Gui.Chart;
                      using NinjaTrader.Gui.SuperDom;
                      using NinjaTrader.Data;
                      using NinjaTrader.NinjaScript;
                      using NinjaTrader.Core.FloatingPoint;
                      using NinjaTrader.Gui.Tools;
                      
                      #endregion
                      
                      //This namespace holds Add ons in this folder and is required. Do not change it. 
                      namespace NinjaTrader.NinjaScript.AddOns
                      {
                      	
                      	public class Pager : NinjaTrader.NinjaScript.AddOnBase
                      	{
                      	
                      		private System.Windows.Controls.Button myBuyButton;
                      private System.Windows.Controls.Button mySellButton;
                      private System.Windows.Controls.Grid myGrid;
                      		
                      		// Define a custom event method to handle your custom task when the button is clicked
                      private void OnMyButtonClick(object sender, RoutedEventArgs rea)
                      {
                         System.Windows.Controls.Button button = sender as System.Windows.Controls.Button;
                         if (button != null)
                            Print(button.Name + " Clicked");
                      }
                      protected override void OnStateChange()
                      		{
                      			if (State == State.SetDefaults)
                      			{
                      				Description							= @"Enter the description for your new custom Add on here.";
                      				Name								= "Pager";
                      				 IsOverlay = true;
                      			}
                      			else if (State == State.Configure)
                      			{
                      			}
                      			 // Once the NinjaScript object has reached State.Historical, our custom control can now be added to the chart
                         else if (State == State.Historical)
                         {
                            // Grid already exists
                            if (UserControlCollection.Contains(myGrid))
                                  return;
                            
                            // Because we're dealing with UI elements, we need to use the Dispatcher which created the object
                            // in order for us to update the contents that are created on the main UI thread otherwise you will run into threading errors
                            // e.g, "Error on calling 'OnStateChange' method: You are accessing an object which resides on another thread."
                            ChartControl.Dispatcher.Invoke((() =>
                            {
                               // Add a control grid which will host our custom buttons
                               myGrid = new System.Windows.Controls.Grid
                               {
                                  Name = "MyCustomGrid",
                                  // Align the control to the top right corner of the chart
                                  HorizontalAlignment = HorizontalAlignment.Right,
                                  VerticalAlignment = VerticalAlignment.Top,
                               };
                       
                               // Define the two columns in the grid, one for each button
                               System.Windows.Controls.ColumnDefinition column1 = new System.Windows.Controls.ColumnDefinition();
                               System.Windows.Controls.ColumnDefinition column2 = new System.Windows.Controls.ColumnDefinition();
                               
                               // Add the columns to the Grid
                               myGrid.ColumnDefinitions.Add(column1);
                               myGrid.ColumnDefinitions.Add(column2);
                       
                               // Define the custom Buy Button control object
                               myBuyButton = new System.Windows.Controls.Button
                               {
                                  Name = "MyBuyButton",
                                  Content = "Buy",
                                  Foreground = Brushes.White,
                                  Background = Brushes.Green
                               };
                       
                               // Define the custom Sell Button control object
                               mySellButton = new System.Windows.Controls.Button
                               {
                                  Name = "MySellButton",
                                  Content = "Sell",
                                  Foreground = Brushes.White,
                                  Background = Brushes.Red
                               };
                       
                               // Subscribe to each buttons click event to execute the logic we defined in OnMyButtonClick()
                               myBuyButton.Click += OnMyButtonClick;
                               mySellButton.Click += OnMyButtonClick;
                       
                               // Define where the buttons should appear in the grid
                               System.Windows.Controls.Grid.SetColumn(myBuyButton, 0);
                               System.Windows.Controls.Grid.SetColumn(mySellButton, 1);
                       
                               // Add the buttons as children to the custom grid
                               myGrid.Children.Add(myBuyButton);
                               myGrid.Children.Add(mySellButton);
                       
                               // Finally, add the completed grid to the custom NinjaTrader UserControlCollection
                               UserControlCollection.Add(myGrid);
                       
                            }));
                         }
                       
                         // When NinjaScript object is removed, make sure to unsubscribe to button click events
                         else if (State == State.Terminated)
                         {
                            // Again, we need to use a Dispatcher to interact with the UI elements
                            ChartControl.Dispatcher.Invoke((() =>
                            {         
                               if (myGrid != null)
                               {
                                  if (myBuyButton != null)
                                  {
                                     myGrid.Children.Remove(myBuyButton);
                                     myBuyButton.Click -= OnMyButtonClick;
                                     myBuyButton = null;
                                  }
                                  if (mySellButton != null)
                                  {
                                     myGrid.Children.Remove(mySellButton);
                                     mySellButton.Click -= OnMyButtonClick;
                                     mySellButton = null;
                                  }
                               }
                            }));
                         }
                      		}
                      
                      		protected override void OnWindowCreated(Window window)
                      		{
                      			
                      		}
                      
                      		protected override void OnWindowDestroyed(Window window)
                      		{
                      			
                      		}
                      
                      	}
                      }

                      Comment


                        #12
                        You would not actually use the same approach in an indicator or AddOn (I should have clarified there). UserControlCollection is inherited from IndicatorBase, and is not available in AddOns (same applies to IsOverlay).

                        For AddOns, the process is a bit more straightfoward, and veers out of the realm of NinjaScript proper. In an AddOn, you will need to grab an instance of the window which is the chart you are looking for (or all chart windows), then add visual elements via the standard WPF methodology. Rather than using XAML, you can use the equivalent C# code-behind syntax to instantiate and add visual elements to any window.

                        Attached is a more appropriate example for accomplishing this in an AddOn. Take a look specifically at the code in OnWindowCreated(). In this example, we are finding any window that is a chart, then instantiating a Button, then applying the Button to a specific place in the window. You should be able to use this same methodology to instantiate and add a text box to your desired location on charts.
                        Attached Files
                        Dave I.NinjaTrader Product Management

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Perr0Grande, Today, 08:16 PM
                        0 responses
                        2 views
                        0 likes
                        Last Post Perr0Grande  
                        Started by elderan, Today, 08:03 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post elderan
                        by elderan
                         
                        Started by algospoke, Today, 06:40 PM
                        0 responses
                        10 views
                        0 likes
                        Last Post algospoke  
                        Started by maybeimnotrader, Today, 05:46 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post maybeimnotrader  
                        Started by quantismo, Today, 05:13 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post quantismo  
                        Working...
                        X