Form/Window Indicator appears in all open workspaces - NinjaTrader Programming | futures io social day trading
futures io futures trading


Form/Window Indicator appears in all open workspaces
Updated: Views / Replies:2,169 / 10
Created: by bmtrader333 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
 2  
 
Thread Tools Search this Thread
 

Form/Window Indicator appears in all open workspaces

  #1 (permalink)
Elite Member
Greensboro, NC, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES, NQ
 
Posts: 12 since Jan 2012
Thanks: 1 given, 5 received

Form/Window Indicator appears in all open workspaces

Hello,

I'm having a problem with a custom ninjascript indicator I built for NT7. The indicator creates its own Form/Window to display information in.

My problem is this: when I add my indicator to a chart in one workspace, the form/window it creates shows up not only in the workspace in which the indicator's home chart is located, but also in all other open workspaces in my NinjaTrader 7 client.

I know it is possible to get my indicator's form/window to only show up in the workspace in which it is applied (I have a paid-for 3rd-party indicator that does this successfully), but I don't know how to do this. Can anyone tell me how to do this or at least point me in the right direction?

(When I asked this question on the NT forums, I just got the dreaded reply that my problem was "unsupported".)

Thanks in advance for any help with this question.

Reply With Quote
The following user says Thank You to bmtrader333 for this post:
 
  #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
canton mi
 
Futures Experience: Beginner
Platform: ninja xtrader
Favorite Futures: tf, es
 
Posts: 233 since Jan 2014
Thanks: 317 given, 145 received



bmtrader333 View Post
Hello,

I'm having a problem with a custom ninjascript indicator I built for NT7. The indicator creates its own Form/Window to display information in.

My problem is this: when I add my indicator to a chart in one workspace, the form/window it creates shows up not only in the workspace in which the indicator's home chart is located, but also in all other open workspaces in my NinjaTrader 7 client.

I know it is possible to get my indicator's form/window to only show up in the workspace in which it is applied (I have a paid-for 3rd-party indicator that does this successfully), but I don't know how to do this. Can anyone tell me how to do this or at least point me in the right direction?

(When I asked this question on the NT forums, I just got the dreaded reply that my problem was "unsupported".)

Thanks in advance for any help with this question.

how do you post a forum i cant find the button

Reply With Quote
 
  #4 (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: 803 given, 1,367 received


bmtrader333 View Post
Hello,

I'm having a problem with a custom ninjascript indicator I built for NT7. The indicator creates its own Form/Window to display information in.

You will get more response if you post the indicator and/or image so we can analyze and respond easily.

FWIW

Rejoice in the Thunderstorms of Life . . .
Knowing it's not about Clouds or Wind. . .
But Learning to Dance in the Rain ! ! !
Reply With Quote
The following user says Thank You to DavidHP for this post:
 
  #5 (permalink)
Elite Member
Greensboro, NC, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES, NQ
 
Posts: 12 since Jan 2012
Thanks: 1 given, 5 received

I'm posting the relevant parts of the code below. (The "..." below just represent indicator code that I have omitted from my post.) The indentation got messed up a bit, but I think the code is still fairly readable. This code creates a "reconstructed tape" that is similar to what you'd see with a time & sales window. (Sorry that I can't post a screenshot of this. I tried, but I don't have enough posts here at Big Mike's to be allowed to post an image...)

For some reason, any reconstructed tape form/window that this code creates shows up in all open workspaces in my NT7 client. I want the reconstructed tape window to only show up in the workspace that houses the chart to which this indicator is applied. (In other words, I want the reconstructed tape window to only display in the workspace in which it is applied, and I want the reconstructed tape window to only show up in the available window list of the workspace in which it is applied. Currently, the reconstructed tape window displays in all open workspaces, and it shows up in the available window list of all open workspaces.)

Again, any help in figuring out how to get this reconstructed tape form/window to only show up in the workspace in which it is applied is greatly appreciated. (I know this is possible because the paid-for 3rd party reconstructed tape indicator that I am emulating creates a form/window that displays, and is available for display, only in the workspace that contains the chart to which it is applied.)

 
Code
 
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using System.IO;
using System.Windows.Forms;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{

    public class ReconTickRecorder05 : Indicator
    {

...

		private		Int32			windowX = 30;
		private		Int32			windowY = 30;
		private		Int32			windowWidth = 150;
		private		Int32			windowHeight = 300;
		private		RT_Form 		        RT_Form1;
		private		int				numGridRows = 70;
		private		Color			bidColor = Color.Red;
		private		Color			askColor = Color.Lime;


...

		protected override void OnStartUp()
		{	
			// create window for recon tape
			// Create a new instance of the form.
   			RT_Form1 = new RT_Form(this);
			RT_Form1.createRTWindow();
		}


		protected override void OnTermination()
		{	
			// dispose of recon tape output window
			if (RT_Form1.Exists) { RT_Form1.Dispose(); }
		}

...

		class RT_Form : Form 
		{
			private		ReconTickRecorder05 	myRT;
			private		DataGridView			myDataGridView;	
			private		bool					exists = false;
		
			public RT_Form(ReconTickRecorder05 outerRT)
			{
				myRT = outerRT;
				exists = true;
			}
			
			public void createRTWindow()
			{
				this.FormBorderStyle = FormBorderStyle.Sizable;
				// Set the caption bar text of the form. 
				if (myRT.Instrument != null) { this.Text = myRT.Instrument.MasterInstrument.Name + "_RT"; }
				else { this.Text = "RTape"; }
				this.MaximizeBox = true;
				this.MinimizeBox = true;
				
				// create DataGridView and add it to form
				myDataGridView = new DataGridView();		
				this.Controls.Add(myDataGridView);

				// set properties of myDataGridView
				myDataGridView.ColumnCount = 3;
				myDataGridView.Name = "RT_DataGridView";
myDataGridView.AutoSizeColumnsMode=DataGridViewAutoSizeColumnsMode.DisplayedCellsExceptHeader;	
				myDataGridView.CellBorderStyle = DataGridViewCellBorderStyle.None;
				myDataGridView.RowHeadersVisible = false;
				myDataGridView.Font = new Font(System.Drawing.FontFamily.GenericSansSerif, (float)8.25);
				myDataGridView.AllowUserToAddRows = false;
				myDataGridView.AllowUserToDeleteRows = false;
				myDataGridView.AllowUserToOrderColumns = false;
				myDataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
				myDataGridView.AllowUserToResizeColumns = false;
				myDataGridView.AllowUserToResizeRows = false;
				myDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
				myDataGridView.MultiSelect = false;
				myDataGridView.Dock = DockStyle.Fill;
				myDataGridView.ReadOnly = true;			
				myDataGridView.ColumnHeadersVisible = false;
				myDataGridView.RowsDefaultCellStyle.BackColor = Color.Black;
				myDataGridView.RowsDefaultCellStyle.ForeColor = Color.Red;
				myDataGridView.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
				myDataGridView.RowTemplate.Height = 13;
				myDataGridView.ScrollBars = System.Windows.Forms.ScrollBars.None;

				myDataGridView.Columns[0].Name = "Time";
				myDataGridView.Columns[1].Name = "Price";
				myDataGridView.Columns[2].Name = "Volume";
				myDataGridView.Columns[2].MinimumWidth = 30;
				
				// Display the form.
				this.StartPosition = FormStartPosition.Manual;
				this.Location = new Point(myRT.WindowX, myRT.WindowY);
				this.Size = new Size(myRT.WindowWidth, myRT.WindowHeight);
				this.Show();
			}
			
			public void printRTRow(string[] rowArray, int rowType)
			{
				// print new row
				myDataGridView.Rows.Insert(0, rowArray);
				if (rowType == 1) { myDataGridView.Rows[0].DefaultCellStyle.ForeColor = myRT.BidColor; }
				else if (rowType == 2 ) { myDataGridView.Rows[0].DefaultCellStyle.ForeColor = myRT.AskColor; }
				else { myDataGridView.Rows[0].DefaultCellStyle.ForeColor = Color.Beige; }
				
				// remove any row beyond specified NumGridRows as it is created
				if (myDataGridView.Rows.Count > myRT.NumGridRows) {
					myDataGridView.Rows.RemoveAt(myDataGridView.Rows.Count - 1);	
				}
			}
			
			protected override void OnLocationChanged(System.EventArgs e)
			{
				try
				{
					myRT.WindowX = this.Bounds.X;
					myRT.WindowY = this.Bounds.Y;
				}
				catch{}
				base.OnLocationChanged(e);
			}

			protected override void OnResizeEnd(System.EventArgs e)
			{
				try
				{
					myRT.WindowWidth = this.Bounds.Width;
					myRT.WindowHeight = this.Bounds.Height;	
				}
				catch{}
				base.OnResizeEnd(e);
			}
			
			protected override void OnClosed(System.EventArgs e)
			{
				try
				{
					this.exists = false;
				}
				catch{}
				base.OnClosed(e);
			}
						
			#region RT_Form_Properties
			
			public bool Exists
			{
				get { return exists; }
			}
			
			#endregion
			
			
		} // end class RT_Form


        #region Properties

...

	[Description("Number of rows in Recon Tape Output Window")]
        [GridCategory("2. Recon Tape Output Window")]
        [Gui.Design.DisplayNameAttribute("1. NumRTRows")]
        public int NumGridRows
        {
            get { return numGridRows; }
            set { numGridRows = Math.Max(1, value); }
        }		
		
	[XmlIgnore()]
	[Description("Color of Bids in Recon Tape Output Window")]
        [GridCategory("2. Recon Tape Output Window")]
        [Gui.Design.DisplayNameAttribute("2. Bid Color")]
        public Color BidColor
        {
            get { return bidColor; }
            set { bidColor = value; }
        }
		
	[Browsable(false)]
	public string BidColorSerialize
	{
		get { return NinjaTrader.Gui.Design.SerializableColor.ToString(bidColor); }
		set { bidColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
	}
		
	[XmlIgnore()]
	[Description("Color of Asks in Recon Tape Output Window")]
        [GridCategory("2. Recon Tape Output Window")]
        [Gui.Design.DisplayNameAttribute("3. Ask Color")]
        public Color AskColor
        {
            get { return askColor; }
            set { askColor = value; }
        }
		
	[Browsable(false)]
	public string AskColorSerialize
	{
		get { return NinjaTrader.Gui.Design.SerializableColor.ToString(askColor); }
		set { askColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
	}
		
	[Description("Recon Tape Output Window X position")]
        [GridCategory("2. Recon Tape Output Window")]
        [Gui.Design.DisplayNameAttribute("4. Window X position")]
        public Int32 WindowX
        {
            get { return windowX; }
            set { windowX = Math.Max(0, value); }
        }
		
	[Description("Recon Tape Output Window Y position")]
        [GridCategory("2. Recon Tape Output Window")]		
        [Gui.Design.DisplayNameAttribute("5. Window Y position")]
        public Int32 WindowY
        {
            get { return windowY; }
            set { windowY = Math.Max(0, value); }
        }
		
	[Description("Recon Tape Output Window width")]
        [GridCategory("2. Recon Tape Output Window")]		
        [Gui.Design.DisplayNameAttribute("6. Window width")]
        public Int32 WindowWidth
        {
            get { return windowWidth; }
            set { windowWidth = Math.Max(20, value); }
        }
		
	[Description("Recon Tape Output Window height")]
        [GridCategory("2. Recon Tape Output Window")]		
        [Gui.Design.DisplayNameAttribute("7. Window height")]
        public Int32 WindowHeight
        {
            get { return windowHeight; }
            set { windowHeight = Math.Max(20, value); }
        }		
		
        #endregion


    } // end class ReconTickRecorder05

} // namespace


Last edited by bmtrader333; March 5th, 2014 at 12:58 PM.
Reply With Quote
 
  #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: 803 given, 1,367 received


bmtrader333 View Post
I'm posting the relevant parts of the code below. (The "..." below just represent indicator code that I have omitted from my post.)



With 'secret code' it is probably best for you to go to the Ninjatrader website and see if you can hire a professional coder to resolve the issue.

Maybe someone here will try to tackle the problem with your code, but with incomplete code you probably will only get incomplete answers and no resolution.

L8r

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
Greensboro, NC, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES, NQ
 
Posts: 12 since Jan 2012
Thanks: 1 given, 5 received

Thanks for your input DavidHP...

But actually, in response to DavidHP's most friendly feedback, I have attached a working version of my indicator code example above. It's the exact same code as above, minus the points of ellipsis, and with empty Initialize() and OnBarUpdate() methods added. For anyone who wants to have working code to play with, this indicator code illustrates the problem. When you apply it to a chart, it creates a form/window that displays in all open workspaces on your NT7 client and that shows up in the list of available windows for every open workspace on your NT7 client. (Make sure to have at least two workspaces open when you apply this indicator to a chart to be able to see this effect.)

It's easy to fix my problem by just setting the form's Visible property to false whenever the workspace in which it is originally applied is not the workspace currently being viewed. (When the form is first created/instantiated, set a variable to hold the "name" of the workspace currently being viewed. Later checks compare this workspace "name" to the "name" of the workspace currently being viewed. If they don't match, make the form invisible. If they do match, make the form visible again.)

Unfortunately, this requires that I be able to get at which workspace is currently being viewed through ninjascript code.

Does anyone on here know what calls to make in ninjascript in order to get at workspace-related info?

Thanks in advance for any help with this question.

Attached Files
Register to download File Type: zip ReconTickRecorder05.zip (2.5 KB, 20 views)

Last edited by bmtrader333; March 6th, 2014 at 01:45 PM.
Reply With Quote
 
  #8 (permalink)
Elite Member
Greensboro, NC, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES, NQ
 
Posts: 12 since Jan 2012
Thanks: 1 given, 5 received

Haven't had power since the night of my last post due to an ice storm that hit my area...

In any case, I now have a semi-solution to my problem that's probably about as good as I'm going to get. Thanks to Gomi for his above/sticky post about the free utility/program Microsoft FxCop. (I'm still 1 post shy of being able to post links... but this sticky link is at the top of the NinjaTrader Programming front-page, and it's entitled: How to check your code using Visual Studio and FxCop.)

I didn't use FxCop to analyze my indicator code, but I did point it to the targets NinjaTrader.Custom.dll, NinjaTrader.Core.dll, and to Ninjatrader.exe in order to get a class-hierarchy/tree to examine. After perusing around around a little, I was lucky enough to find what I needed in the class-hierarchy/tree of NinjaTrader.Core.dll.

NinjaTrader 7 has a public static class in the NinjaTrader.Gui namespace called NinjaTrader.Gui.WorkspaceOptions. Within this class is a public static method called NinjaTrader.Gui.WorkspaceOptions.GetCurrentFilename() which returns a string that is the filepath to the xml file that your current workstation is saved to. This will be something like:

C:\Users\<user_name>\Documents\NinjaTrader 7\workspaces\MyWorkspace.xml

The last part of the string is always <the_name_of_your_current_workspace>.xml.

So, once you have this string, you can parse it to get the name of the current workspace. (You could also just use the entire filename of the current workspace in future comparisons, without parsing out the name, if you want to.)

From there, you can toggle the Visible property of the form between true and false based on the name (or filename) of the current workspace (see my previous post for the basic logic behind this toggling) in order to make sure your form/window only shows up in the workspace where the indicator that creates it is applied.


In the solution I came up with, I actually created a boolean variable (universalRTVisibility) to allow you to purposefully show the indicator's form/window in all workspaces if you want to. Since, the full code for this indicator implements something like a time & sales window that gets called at every market data event, this helps to increase efficiency significantly by allowing one to run as few instances of the indicator as possible. If you also use a form/window in an indicator that uses a lot of CPU cycles, you might want to run as few instances of it as possible, as well. Of course, if your workspaces are not set up to allow for this (for example, if the indicator's form/window is not positioned in the same place in every workspace), then you'll probably just want to contain the indicator's form/window within the workspace in which it is applied. Again, with the solution I came up with, you can choose to set things up either way.

I have attached a new version of my previously attached indicator that shows the solution to my problem using the above call and a little bit of logic. Unfortunately, this solution only toggles visibility of the indicator's form/window off/on as instrument market data arrives to the chart where the indicator is applied. In slow markets this could cause the indicator's form/window to show up in workspaces where it is not applied until a market data event arrives. Also, when the indicator is applied to a chart before/after the chart's session hours, the indicator's form/window will remain visible and available in all workspaces until a market data event arrives, regardless of the value of universalRTVisibility. Finally, in the worst case scenario, with universalRTVisibility set to false, you could be viewing a workspace that does not house your indicator when the market session for your indicator's chart ends. In such case, switching to the workspace that houses your indicator will not cause the indicator to turn visible because no market events will be arriving for the chart/instrument that houses your indicator. In such case, you can just reapply your indicator to get its form/window to show up again.

Most of the time, though, especially during regular session hours in reasonably "busy" markets, the form/window created by this indicator will appear and disappear fairly quickly as you switch from workspace to workspace, provided the universalRTVisibility flag is set to false. And again, if you set the universalRTVisibility flag to true, the form/window this indicator creates will remain visible and available in all open workspaces as you switch between them.

If anyone else can come up with a more elegant solution, that would be great. NinjaTrader.Gui.WorkspaceOptions does have a method, OnSwitchWorkspace(System.Object, System.EventArgs), that looks like it could be promising. But this method is both static and private. I have been unable to override this method for these reasons.

Hope this info helps anyone who has a similar problem to the one I had and/or anyone who may want to access workspace-related calls from within Ninjascript in NinjaTrader 7 for whatever reason.

Attached Files
Register to download File Type: zip ReconTickRecorder05_Solution.zip (3.0 KB, 36 views)

Last edited by bmtrader333; March 11th, 2014 at 02:20 PM.
Reply With Quote
The following 2 users say Thank You to bmtrader333 for this post:
 
  #9 (permalink)
Elite Member
Greensboro, NC, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES, NQ
 
Posts: 12 since Jan 2012
Thanks: 1 given, 5 received

Now that I am allowed to post links, I thought I would add some info about the version of FxCop that I used.

First, I downloaded and installed Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 from this webpage:

https://www.microsoft.com/en-us/download/details.aspx?id=3138

This SDK does not install FxCop, but it provides a link to do so: "Tools/Install Microsoft FXCop" once it is installed. (Locate this link under the "Microsoft Windows SDK v7.0" link in the Windows 7 Start menu once the SDK is installed.)

Clicking on the "Install Microsoft FXCop" link installs Microsoft FXCop v1.36 that generates its own Start menu link: "Microsoft FxCop" under Windows 7.

FxCop v1.36 is the tool I used to explore NinjaTrader 7's class-hierarchies/trees as described in my previous post.


Last edited by bmtrader333; March 11th, 2014 at 06:32 PM.
Reply With Quote
 
  #10 (permalink)
Elite Member
Greensboro, NC, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES, NQ
 
Posts: 12 since Jan 2012
Thanks: 1 given, 5 received


Just to streamline things a bit for those who may be interested, here is a direct link to Gomi's most helpful post about how to use Microsoft FXCop:

https://futures.io/ninjatrader-programming/3730-how-check-your-code-using-visual-studio-fxcop.html


Last edited by bmtrader333; March 31st, 2014 at 06:37 PM.
Reply With Quote

Reply



futures io > > > > > Form/Window Indicator appears in all open workspaces

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
HideTitleBar Indicator -- NinjaTrader Title Bar and Window Frame Modification vvhg The Elite Circle 123 November 29th, 2017 06:14 AM
Can I display a ninjatrader indicator in a window without the price panel ? podski NinjaTrader 11 October 9th, 2014 03:50 PM
[MC] indicator - Time Window Nicolas11 The Elite Circle 2 April 6th, 2012 02:56 PM
Why AT&T/T-Mobile Deal Appears to Be Dead Already Quick Summary News and Current Events 0 September 1st, 2011 07:00 PM
Volitility indicator question - Open - Open / open - close / close to open andresimon NinjaTrader 2 September 27th, 2010 01:33 AM


All times are GMT -4. The time now is 10:47 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-14 in 0.17 seconds with 20 queries on phoenix via your IP 54.90.207.75