Add Control to Chart - vvhg needs coding help - NinjaTrader Programming | futures io social day trading
futures io futures trading


Add Control to Chart - vvhg needs coding help
Updated: Views / Replies:1,737 / 6
Created: by vvhg Attachments:2

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Add Control to Chart - vvhg needs coding help

  #1 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received

Add Control to Chart - vvhg needs coding help

I am trying to add a control (a TextBox in this example) to a chart.
Unfortunately everything I have tried so far creates a textbox about the size of the toolbar

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


 
Code
Form thechart = ChartControl.FindForm();
				
				if (thechart != null)
				{
					textBox2 = new System.Windows.Forms.TextBox();
					textBox2.Dock = DockStyle.Fill;
					textBox2.Visible = true;
					textBox2.Location = new System.Drawing.Point(500, 500);
					textBox2.Size = new System.Drawing.Size(750, 500);
					textBox2.Text = "ChartBox";
					thechart.Controls.Add(textBox2);
					textBox2.BringToFront();
				}
I also tried ChartControl.ChartPanel.FindForm() but the result is the same...

To all the geniuses out there...e.g. @gomi, @Xav1029, @Fat Tails, @1LotTrader, @monpere, @ThatManFromTexas, @Silvester17, @NJAMC and all the others...

vvhg

Hic Rhodos, hic salta.
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Tampa, FL
 
Futures Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,374 since Dec 2011
Thanks: 1,452 given, 3,354 received


@vvhg I am currently on a programming hiatus and have never done this before, however I know you are a quick learner so take a look at https://futures.io/download/vip_elite_circle/1194-download.html?view . This uses a dropdown menu to add functionality.

London Calling
Reply With Quote
The following 2 users say Thank You to Xav1029 for this post:
 
  #4 (permalink)
Elite Member
glostrup, denmark
 
Futures Experience: Advanced
Platform: Custom platform
Broker/Data: CQG
Favorite Futures: Futures, Options, Stocks
 
ktrader's Avatar
 
Posts: 249 since Aug 2011
Thanks: 151 given, 274 received


vvhg View Post
I am trying to add a control (a TextBox in this example) to a chart.
Unfortunately everything I have tried so far creates a textbox about the size of the toolbar

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


 
Code
Form thechart = ChartControl.FindForm();
			

				if (thechart != null)
				{
					textBox2 = new System.Windows.Forms.TextBox();
					textBox2.Dock = DockStyle.Fill;
					textBox2.Visible = true;
					textBox2.Location = new System.Drawing.Point(500, 500);
					textBox2.Size = new System.Drawing.Size(750, 500);
					textBox2.Text = "ChartBox";
					thechart.Controls.Add(textBox2);
					textBox2.BringToFront();
				}
I also tried ChartControl.ChartPanel.FindForm() but the result is the same...

To all the geniuses out there...e.g. @gomi, @Xav1029, @Fat Tails, @1LotTrader, @monpere, @ThatManFromTexas, @Silvester17, @NJAMC and all the others...

vvhg

HI,

You can do something like this:

 
Code
      protected override void Initialize()
        {
            Overlay				= true;
     	     Form thechart = ChartControl.FindForm();
			System.Windows.Forms.Panel cc = new System.Windows.Forms.Panel();
			Label ll = new Label();
			ll.Text="hello";
			cc.Controls.Add(ll);
			cc.Anchor=AnchorStyles.Bottom ;
			cc.Dock = DockStyle.Bottom;
			
			thechart.Controls.Remove(ChartControl);
			thechart.Controls.Add(ChartControl);
			thechart.Controls.Add(cc);
	
		}
will look like:

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


--ktrader


Last edited by ktrader; November 25th, 2012 at 04:07 PM. Reason: added screenshot
Reply With Quote
The following 6 users say Thank You to ktrader for this post:
 
  #5 (permalink)
Elite Member
Crete, IL/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker/Data: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Favorite Futures: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 171 since Aug 2009
Thanks: 99 given, 48 received

Hello

this is the best way

 
Code
    // Variables
    private ToolStrip strip = null;
    private Control[] controls = null;
    private ToolStripTextBox tstbSpencer;
    private bool buttonsLoaded = false;
    private Font regularFont = null;

    private ToolStripButton btnSubmit= null;

	public override void Dispose() // these are taken off when chart is refreshed so no multiple objects
	{
		if (buttonsLoaded == true)
		{
			strip.Items.Remove(btnSubmit);
			strip.Items.Remove(tstbSpencer);
		}
	}
        protected override void Initialize()
        {
			CalculateOnBarClose = true;
			regularFont = new Font("Arial", 8);
        }
        // this is the event that happens when button is clicked.  
	private void btnSubmit_Click(object sender, EventArgs e)
	{
		
		MessageBox.Show(tstbSpencer.Text.ToString());
				
	}
        protected override void OnStartUp()
	{
		controls = ChartControl.Controls.Find("tsrTool", false);
			
		if (controls.Length > 0)
		{
			btnSubmit= new ToolStripButton();
			btnSubmit.Font = regularFont;
        		btnSubmit.ForeColor = Color.Black;
			btnSubmit.BackColor = Color.Green;
			btnSubmit.Text = "Submit";
			strip = (ToolStrip)controls[0];
				
			btnSubmit.Click += btnSubmit_Click; // register event
				
			tstbSpencer = new ToolStripTextBox();
			tstbSpencer.Size = new System.Drawing.Size(100, 20);
				
			strip.Items.Add(tstbSpencer); // add ToolStripTextBox to the ToolStrip
                        strip.Items.Add(btnSubmit); // add button to the ToolStrip
				
			buttonsLoaded = true;
		}
	}
that is pretty much it.

I found out how to add a button from NinjaTrader's example using the

 
Code
controls = ChartControl.Controls.Find("tsrTool", false);
for the TextBox I googled ToolStrip and TextBox and found ToolStripTextBox
I then opened visual studio and created a Forms project and then added a ToolStrip, then added a TextBox

Then I opened the GUI code Form.Designer.cs
and found out what the code behind it was using
I then simply added that code here in which case was just specifying a size

anyway, that is the logic behind making it work is add it in visual studio and grab that code and try to fit it in here


Last edited by spinnybobo; June 2nd, 2015 at 05:24 AM.
Reply With Quote
The following user says Thank You to spinnybobo for this post:
 
  #6 (permalink)
Market Wizard
New Orleans, La (Mardi Gras City)
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Ninjatrader / Optimus Futures / AmpFutures
Favorite Futures: ES / 6E / 6B / CL
 
DavidHP's Avatar
 
Posts: 1,002 since Aug 2009
Thanks: 802 given, 1,367 received

Can you post an image of the result?



spinnybobo View Post
Hello
this is the best way

 
Code
    // Variables
    private ToolStrip strip = null;
    private Control[] controls = null;
    private ToolStripTextBox tstbSpencer;
    private bool buttonsLoaded = false;
    private Font regularFont = null;

    private ToolStripButton btnSubmit= null;

	public override void Dispose() // these are taken off when chart is refreshed so no multiple objects
	{
		if (buttonsLoaded == true)
		{
			strip.Items.Remove(btnSubmit);
			strip.Items.Remove(tstbSpencer);
		}
	}
        protected override void Initialize()
        {
			CalculateOnBarClose = true;
			regularFont = new Font("Arial", 8);
        }
        // this is the event that happens when button is clicked.  
	private void btnSubmit_Click(object sender, EventArgs e)
	{
		
		MessageBox.Show(tstbSpencer.Text.ToString());
				
	}
        protected override void OnStartUp()
	{
		controls = ChartControl.Controls.Find("tsrTool", false);
			
		if (controls.Length > 0)
		{
			btnSubmit= new ToolStripButton();
			btnSubmit.Font = regularFont;
        		btnSubmit.ForeColor = Color.Black;
			btnSubmit.BackColor = Color.Green;
			btnSubmit.Text = "Submit";
			strip = (ToolStrip)controls[0];
				
			btnSubmit.Click += btnSubmit_Click; // register event
				
			tstbSpencer = new ToolStripTextBox();
			tstbSpencer.Size = new System.Drawing.Size(100, 20);
				
			strip.Items.Add(tstbSpencer); // add ToolStripTextBox to the ToolStrip
                        strip.Items.Add(btnSubmit); // add button to the ToolStrip
				
			buttonsLoaded = true;
		}
	}
that is pretty much it.

I found out how to add a button from NinjaTrader's example using the

 
Code
controls = ChartControl.Controls.Find("tsrTool", false);
for the TextBox I googled ToolStrip and TextBox and found ToolStripTextBox
I then opened visual studio and created a Forms project and then added a ToolStrip, then added a TextBox

Then I opened the GUI code Form.Designer.cs
and found out what the code behind it was using
I then simply added that code here in which case was just specifying a size

anyway, that is the logic behind making it work is add it in visual studio and grab that code and try to fit it in here


Rejoice in the Thunderstorms of Life . . .
Knowing it's not about Clouds or Wind. . .
But Learning to Dance in the Rain ! ! !
Reply With Quote
 
  #7 (permalink)
Elite Member
Crete, IL/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker/Data: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Favorite Futures: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 171 since Aug 2009
Thanks: 99 given, 48 received


DavidHP View Post
Can you post an image of the result?

Hello

yes here is an image of the result. sorry it took a while

Attached Thumbnails
Add Control to Chart - vvhg needs coding help-textbox-pic.png  
Reply With Quote
The following 2 users say Thank You to spinnybobo for this post:

Reply



futures io > > > > > Add Control to Chart - vvhg needs coding help

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add Strategy in a chart? dream3r NinjaTrader 7 October 2nd, 2014 03:32 AM
Learning self control shipolito Elite Trading Journals 3 June 21st, 2012 12:52 PM
Add buttons to your chart puppeye The Elite Circle 2 September 22nd, 2011 02:34 AM
Learning Chart Control Programming zeller4 NinjaTrader Programming 7 May 8th, 2011 03:09 AM
add custom bar type to chart selection SARdynamite NinjaTrader Programming 15 July 8th, 2010 11:53 AM


All times are GMT -4. The time now is 11:00 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-11 in 0.10 seconds with 20 queries on phoenix via your IP 54.145.16.43