NexusFi: Find Your Edge


Home Menu

 





Moving the ChartTrader buttons down


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Mindset with 5 posts (0 thanks)
    2. looks_two Otterly with 3 posts (0 thanks)
    3. looks_3 Tasker_182 with 2 posts (0 thanks)
    4. looks_4 ktrader with 2 posts (6 thanks)
    1. trending_up 3,617 views
    2. thumb_up 6 thanks given
    3. group 4 followers
    1. forum 11 posts
    2. attach_file 1 attachments




 
Search this Thread

Moving the ChartTrader buttons down

  #1 (permalink)
 
Otterly's Avatar
 Otterly 
Zurich, Switzerland
 
Experience: Intermediate
Platform: Ninja, CTS, TOS
Trading: ES, TF, CL, NQ, GC
Posts: 131 since Aug 2011
Thanks Given: 251
Thanks Received: 62

At the moment when ChartTrader is opened on the right side of the chart, the buttons are aligned from the top.

Is there a way, to amend the code, to make a gap at the top? So that all the buttons are pushed downwards a certain number of pixels?

My screen is very tall, and the buttons are all at the top, I want to move them down so they are closer to the middle/bottom of the screen.

Thanks for any help.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Request for MACD with option to use different MAs for fa …
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
ZombieSqueeze
Platforms and Indicators
NexusFi Journal Challenge - April 2024
Feedback and Announcements
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
58 thanks
Battlestations: Show us your trading desks!
55 thanks
NexusFi site changelog and issues/problem reporting
48 thanks
What percentage per day is possible? [Poll]
31 thanks
GFIs1 1 DAX trade per day journal
29 thanks

  #2 (permalink)
 
ktrader's Avatar
 ktrader 
glostrup, denmark
 
Experience: Advanced
Platform: Custom platform
Broker: CQG
Trading: Futures, Options, Stocks
Posts: 249 since Aug 2011
Thanks Given: 152
Thanks Received: 275

One way of doing it is to move the buttons from code, for example an indicator (or other code you are running that have access to the chart-window).

here is a rough example of how to do it in an indicator:

Just set the "pixels" variable to whatever number of pixels you want the buttons to be moved down.

 
Code
Namespace NinjaTrader.Indicator
{
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class MoveButtons : Indicator
    {
        #region Variables
			
        // User defined variables (add any user defined variables below)
			private int pixels = 100;
        #endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
			this.Overlay=true;
		}

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.

			if (CurrentBar==0) {			
				
								
				Control.ControlCollection ccol = ChartControl.Controls;	
				Control ch = ccol["pnlChartTrader"];
				if (ch!=null) {
					Control ct = ch.Controls["ctrChartTraderControl"];					
					if (ct!=null) {
						Control tb = ct.Controls["btnChartTraderVisible"];
						if (tb!=null) {
							if (tb.Top==0) {
								int cclen = ct.Controls.Count;
								for (int i=0;i<cclen;i++) {
									ct.Controls[i].Top+=pixels;
								}
							}
						}					
					}
				}
			}

        }

        #region Properties

        #endregion
    }
}
--ktrader

Reply With Quote
The following 2 users say Thank You to ktrader for this post:
  #3 (permalink)
 
Otterly's Avatar
 Otterly 
Zurich, Switzerland
 
Experience: Intermediate
Platform: Ninja, CTS, TOS
Trading: ES, TF, CL, NQ, GC
Posts: 131 since Aug 2011
Thanks Given: 251
Thanks Received: 62


Fantastic Ktrader, thankyou for your help.

I have put your code into a new indicator, but am getting an error code on compiling. Sorry for my noobness.

Lines 44 - 49 are getting the error "The type or namespace name "Control" could not be found (are you missing a using directive or an assembely reference?).

Sorry, I understand what to do to resolve this.

Started this thread Reply With Quote
  #4 (permalink)
 
ktrader's Avatar
 ktrader 
glostrup, denmark
 
Experience: Advanced
Platform: Custom platform
Broker: CQG
Trading: Futures, Options, Stocks
Posts: 249 since Aug 2011
Thanks Given: 152
Thanks Received: 275


Otterly View Post
Fantastic Ktrader, thankyou for your help.

I have put your code into a new indicator, but am getting an error code on compiling. Sorry for my noobness.

Lines 44 - 49 are getting the error "The type or namespace name "Control" could not be found (are you missing a using directive or an assembely reference?).

Sorry, I understand what to do to resolve this.

Thats in System.Windows.Forms namespace. So in the very top of file there are some "using declarations" (you might need to press the "+" to expand them.)

after the last using declaration add this:

using System.Windows.Forms;


I have exported my indicator and attached to this post too - so if you prefer you can just download and import into ninja...

-ktrader

l

Attached Files
Elite Membership required to download: movebuttons.zip
Reply With Quote
The following 4 users say Thank You to ktrader for this post:
  #5 (permalink)
 
Otterly's Avatar
 Otterly 
Zurich, Switzerland
 
Experience: Intermediate
Platform: Ninja, CTS, TOS
Trading: ES, TF, CL, NQ, GC
Posts: 131 since Aug 2011
Thanks Given: 251
Thanks Received: 62

Fantastic!

It works very nicely. ThankYou.

It´s good to know there are people who know what they are doing. Unfortunately, at NinjaTrader their employee gurus said it couldn´t be done. I´ve no surprise that someone from futures.io (formerly BMT) could do it.

Great job Ktrader.

Started this thread Reply With Quote
  #6 (permalink)
 
Mindset's Avatar
 Mindset 
Singapore
 
Experience: Intermediate
Platform: NT
Broker: ib
Trading: MES
Posts: 365 since Sep 2009
Thanks Given: 90
Thanks Received: 291

ktrader
Nice coding. I thought I could enumerate all the buttons in the Chart Trader Container by
Print(ct.Control[i].Name);

but this doesn't produce anything. Any ideas of how to do this?

Reply With Quote
  #7 (permalink)
 
Mindset's Avatar
 Mindset 
Singapore
 
Experience: Intermediate
Platform: NT
Broker: ib
Trading: MES
Posts: 365 since Sep 2009
Thanks Given: 90
Thanks Received: 291

My Bad

 
Code
	foreach(Control control in ct.Controls)
				{
					Print (control.Name);
				}

Reply With Quote
  #8 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
Cedar Rapids, iowa
Legendary Market Wizard
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,401


ktrader View Post
One way of doing it is to move the buttons from code, for example an indicator (or other code you are running that have access to the chart-window).

here is a rough example of how to do it in an indicator:

Just set the "pixels" variable to whatever number of pixels you want the buttons to be moved down.

 
Code
Namespace NinjaTrader.Indicator
{
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class MoveButtons : Indicator
    {
        #region Variables
			
        // User defined variables (add any user defined variables below)
			private int pixels = 100;
        #endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
			this.Overlay=true;
		}

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.

			if (CurrentBar==0) {			
				
								
				Control.ControlCollection ccol = ChartControl.Controls;	
				Control ch = ccol["pnlChartTrader"];
				if (ch!=null) {
					Control ct = ch.Controls["ctrChartTraderControl"];					
					if (ct!=null) {
						Control tb = ct.Controls["btnChartTraderVisible"];
						if (tb!=null) {
							if (tb.Top==0) {
								int cclen = ct.Controls.Count;
								for (int i=0;i<cclen;i++) {
									ct.Controls[i].Top+=pixels;
								}
							}
						}					
					}
				}
			}

        }

        #region Properties

        #endregion
    }
}
--ktrader


Hey ktrader,

just a technical question. It appears the code only operates once but the variable CurrentBar is checked on each onbarupdate. Can the code be executed in OnStartUp instead? (as in I'm too lazy to try and thought I could just ask...)

Regards

Be yourself; everyone else is already taken. Oscar Wilde
Reply With Quote
  #9 (permalink)
 
Mindset's Avatar
 Mindset 
Singapore
 
Experience: Intermediate
Platform: NT
Broker: ib
Trading: MES
Posts: 365 since Sep 2009
Thanks Given: 90
Thanks Received: 291

An alternative is just to use a bool

so...

If(init)
{execute code
set init to false
end code}


Then it only runs once. There are two small bugs in this code. If you refresh, the buttons keep going down and if you remove the code the buttons don't revert back to their original place. I have tried to sort this out but it's beyond my ken at the moment.

Reply With Quote
  #10 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
Cedar Rapids, iowa
Legendary Market Wizard
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,401



Mindset View Post
An alternative is just to use a bool

so...

If(init)
{execute code
set init to false
end code}


Then it only runs once. There are two small bugs in this code. If you refresh, the buttons keep going down and if you remove the code the buttons don't revert back to their original place. I have tried to sort this out but it's beyond my ken at the moment.

He is using CurrentBar ==0 as the bool check. I thought that moving it to onstart-up just eliminates the bool check.

Be yourself; everyone else is already taken. Oscar Wilde
Reply With Quote





Last Updated on January 9, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts