Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

[Request] - ChartTrader access

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

    #31
    Hello, in NT7 it is possible to change the quantity in the Chart Trader with this coding:
    Code:
    private void SampleButton_Click(object sender, RoutedEventArgs e)
    		{
    			((NumericUpDown)ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Controls["nudQuantity"]).Value = RisikoQuantity;
    			((NumericUpDown)ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Controls["nudQuantity"]).Value = RisikoQuantity;
    		}
    But how can we use this in NT8 to update the caculated quantity in the chart trader quantity?

    thanks for helping

    Christian
    Last edited by schranzi9; 03-20-2016, 04:19 AM.

    Comment


      #32
      Hello,

      Thank you for the question.

      Please refer to post #23 for the sample this applies to.

      In the sample you will see:

      Code:
      chartTrader = Window.GetWindow(ChartControl.Parent).FindFirst("ChartWindowChartTraderControl") as ChartTrader;
      						
      if (chartTrader == null)
      {
      	Print("ChartTrader is null");
      	return;
      }
      After this section of code or after checking that chartTrader is not null, all that is required is the following line of syntax:

      Code:
      NinjaTrader.Gui.Tools.QuantityUpDown numericStepper = chartTrader.FindFirst("ChartTraderControlQuantitySelector") as NinjaTrader.Gui.Tools.QuantityUpDown;
      Print(numericStepper.Value);
      Please let me know if I may be of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #33
        Thanks Jesse, that is really what I search, it works fine.

        the next step is to overwrite the Order qty in the chart trader with the new calculated order quantity. I do it at a moment with the button and I can now print out the order quantity change, but how can I update also the Order qty field in the chart trader after I have calculated the new quantity:
        Code:
         private void OnButtonClick(object sender, RoutedEventArgs rea)
        		{
        			System.Windows.Controls.Button button = sender as System.Windows.Controls.Button;
        			if (button == longButton && button.Name == "LongButton" && button.Content == "LONG")
        			{
        				button.Content = "Exit L";
        				button.Name = "ExitLongButton";
        				longButtonClicked = true;
        				NinjaTrader.Gui.Tools.QuantityUpDown numericStepper = chartTrader.FindFirst("ChartTraderControlQuantitySelector") as NinjaTrader.Gui.Tools.QuantityUpDown;
        				numericStepper.Value = TradeQuant;  //TradeQuant default 61000
        				Print(numericStepper.Value);
        				return;
        			}
        Thanks for helping again, Christian

        Comment


          #34
          Hello,

          Thank you for the reply.

          I am unable to run the sample, are you asking how to manually update the GUI? I assume the question is related to the value not being changed in the user interface, is this correct?

          You could try using ForceRefresh to see if that causes the update if that is what you are asking: http://ninjatrader.com/support/helpG...lightsub=force

          Likely because the control is bound to an object, it would be unable to be directly set in this way but the object it uses would need to be set instead. That would be information I do not have though and would need to put a question in with development. Please try using the ForceRefresh first and let me know if this does not work.


          Please let me know if I may be of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #35
            OK I understand. Maybe you can help me with this part of my other question before. After I use the coding to add the Sample Button on the chart trader I will create the sample button smaller. In NT7 I can use

            Code:
            if (ChartControl == null) return;
            			
            			Control ctrader = ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"];
            			
            			SampleButton = new Button();
            			SampleButton.Name = "btnQtySet1";
            			SampleButton.Text = setQty1.ToString();
            			
            			SampleButton.Width = 40;
            			SampleButton.Height = 40;
            			SampleButton.Location = new Point(10, 440);
            			SampleButton.BackColor = btnColor; //Color.Honeydew;
            			SampleButton.Click += new EventHandler(SampleButton_Click);
            			ctrader.Controls.Add(SampleButton);
            In NT8 I can use now
            Code:
            sampleButton = new Button
            						{
            							Content = "Sample Button",
            							Style = System.Windows.Application.Current.TryFindResource("Button") as Style
            						};
            
            						sampleButton.Click += SampleButton_Click;
            						AutomationProperties.SetAutomationId(sampleButton, "SampleButton");
            
            						//this is the main chart trader grid where the default buttons and controls reside
            						mainGrid = chartTrader.FindName("grdMain") as Grid;
            but how can I use the smaller button with weight and height like in the NT7 example now in NT8 ?

            Thanks for helping , Christian

            Comment


              #36
              Hello,

              Thank you for the reply.

              I am unsure what you mean but use the smaller button, are you asking how to control a buttons size in WPF?

              it would be the same as in Winforms, the button would still have a Width and Height property for a specific Size.

              You are using a different expression to create the button in NT8, but the same style code works which looks like the NT7 version as well.

              To add a Width to what you have, you would just need to add a comma or:

              Content = "Sample Button",
              Width = ... ,
              Height = ...,
              Style =....


              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Waxavi, Today, 02:10 AM
              0 responses
              4 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Started by TradeForge, Today, 02:09 AM
              0 responses
              9 views
              0 likes
              Last Post TradeForge  
              Started by Waxavi, Today, 02:00 AM
              0 responses
              2 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Started by elirion, Today, 01:36 AM
              0 responses
              4 views
              0 likes
              Last Post elirion
              by elirion
               
              Started by gentlebenthebear, Today, 01:30 AM
              0 responses
              4 views
              0 likes
              Last Post gentlebenthebear  
              Working...
              X