NexusFi: Find Your Edge


Home Menu

 





Strategy to monitor ALL account orders?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one MXASJ with 5 posts (2 thanks)
    2. looks_two Maza with 3 posts (2 thanks)
    3. looks_3 NinjaTrader with 2 posts (0 thanks)
    4. looks_4 SetFreeByTruth with 2 posts (0 thanks)
    1. trending_up 8,440 views
    2. thumb_up 6 thanks given
    3. group 8 followers
    1. forum 18 posts
    2. attach_file 1 attachments




 
Search this Thread

Strategy to monitor ALL account orders?

  #11 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800


traderwerks View Post
What about something like zeromq in brokerless mode ? Also, there is the windows messaging framework, but I haven't kept up with that one.

Way, way OT but I'd love to find a way to turn this into the Poor Man's TIBCO

NetFPGA

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Are there any eval firms that allow you to sink to your …
Traders Hideout
Deepmoney LLM
Elite Quantitative GenAI/LLM
NexusFi Journal Challenge - April 2024
Feedback and Announcements
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
The Program
18 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #12 (permalink)
SetFreeByTruth
Minneapolis Minnesota
 
Posts: 5 since Mar 2011
Thanks Given: 2
Thanks Received: 0


MXASJ View Post
Have a play with this:

 
Code
Print("Total Open Positions: " + Account.Positions.Count);
System.Collections.IEnumerator ListPositions = Account.Positions.GetEnumerator();
for (int i = 0; i < Account.Positions.Count; i++)
{
ListPositions.MoveNext();
Print("Open Position: " + ListPositions.Current);
}
Please post back if you come up with something useful. I need to send position information to another computer and have not come up with an elegant way to do it yet.

Thank you! That is just what I was looking for. I also see I can use the Account.Orders collection to iterate over orders:

 
Code
int iOrderCount = Account.Orders.Count;
 				
Print("Total Open Orders: " + iOrderCount );
System.Collections.IEnumerator ListOrders = Account.Orders.GetEnumerator();
			
for (int i = 0; i < iOrderCount; i++) {
  ListOrders.MoveNext();
  Print("  Open Orders: " + ListOrders.Current );
}
I wonder why the Account object isn't documented in the NT help file. Anyway, thank you!

Reply With Quote
  #13 (permalink)
 richtobey 
San Antonio
 
Experience: Advanced
Platform: NinjaTrader Interactive Brokers
Broker: Interactive Brokers
Trading: forex
Posts: 45 since Oct 2010
Thanks Given: 0
Thanks Received: 116


I am attempting to trigger an ATM strategy from the SuperDom and then want to find it from a strategy (that is attached to a chart) and execute advanced trail logic that is not possible with an ATM. Specifically, I'm building a strategy that trails behind the 15m bar on a bar by bar basis. But it also, changes it's stop management 15 minutes before or after news. News is downloaded from Forex Factory via their xml interface live from within the strategy. The interface, which is a hidable side panel, will eventually list the news events and allow you to select which news to pay attention to and which to ignore.

I used the code in this thread to enumerate the Strategy collection, but it doesn't contain the strategy's UniqueID. I need the UniqueId to use AtmStrategyChangeStopTarget().

Here is the code I used:
 
Code
                            
            Print("Total Strategies: " Account.Strategies.Count);
            
System.Collections.IEnumerator ListStrategies Account.Strategies.GetEnumerator();

            for (
int i 0Account.Strategies.Counti++)
            {
                
ListStrategies.MoveNext();
                Print(
"Open Strategy: " ListStrategies.Current);
            } 
I also tried this without success:
 
Code
                            
            foreach (IStrategyData strat in StrategyData)
            {
                
//do something
            

One option is to put buttons on my panel to create the entry and ATM from within the strategy. Then I would know the UniqueID, but this reduces flexability to add the trailing stop after the entry is made.

Any ideas?

Attached Thumbnails
Click image for larger version

Name:	Screen shot 2011-04-02 at 9.37.37 AM.png
Views:	211
Size:	40.7 KB
ID:	35736  
Visit my NexusFi Trade Journal Reply With Quote
  #14 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629

@richtobey, an option is maybe to look in the NT database directly, the ID might be there.
I'm writing something like your 2nd option: a strategy with some buttons on an other panel, but without using ATM. That's very flexible.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #15 (permalink)
 Maza 
Cluj-Napoca Cluj/Romania
 
Experience: Intermediate
Platform: NinjaTrader, MetaTrader 4
Broker: FXCM, Continuum
Trading: Forex, Futures
Posts: 12 since Apr 2013
Thanks Given: 6
Thanks Received: 7

G'day guys,

I know I am resurrecting a dead horse here but none the less I need some help in tweaking this idea further.

I have followed and implemented the following code:
 
Code
int ioCount = account.Orders.Count;
System.Collections.IEnumerator ListOrders = account.Orders.GetEnumerator();
for (int i = 0; i < ioCount; i++) {
	ListOrders.MoveNext();
	Print("  Open Orders: " + ListOrders.Current);
}
Do you guys know of a method or a way to call to each individual order properties (like price) so I can use it in code further.

Thanks in advance,

Maza.

Reply With Quote
  #16 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


Maza View Post
G'day guys,

I know I am resurrecting a dead horse here but none the less I need some help in tweaking this idea further.

I have followed and implemented the following code:
 
Code
int ioCount = account.Orders.Count;
System.Collections.IEnumerator ListOrders = account.Orders.GetEnumerator();
for (int i = 0; i < ioCount; i++) {
	ListOrders.MoveNext();
	Print("  Open Orders: " + ListOrders.Current);
}
Do you guys know of a method or a way to call to each individual order properties (like price) so I can use it in code further.

Thanks in advance,

Maza.

You can just use the Orders directly, e.g.

 
Code
Order myOrder = account.Orders[i];
Print(myOrder.OrderType);

Travel Well
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #17 (permalink)
 Maza 
Cluj-Napoca Cluj/Romania
 
Experience: Intermediate
Platform: NinjaTrader, MetaTrader 4
Broker: FXCM, Continuum
Trading: Forex, Futures
Posts: 12 since Apr 2013
Thanks Given: 6
Thanks Received: 7


ratfink View Post
You can just use the Orders directly, e.g.

 
Code
Order myOrder = account.Orders[i];
Print(myOrder.OrderType);

Firstly I would like to thank you ratfink for your timely answer.

I still have one more question that I can't find the answer to. How can I see (from code) what account is selected in the chart trader?

Thanks again,

Maza.

Reply With Quote
Thanked by:
  #18 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


Maza View Post
Firstly I would like to thank you ratfink for your timely answer.

I still have one more question that I can't find the answer to. How can I see (from code) what account is selected in the chart trader?

Thanks again,

Maza.

 
Code
		private void accountChanged (object sender, EventArgs e)
		{
			if (ChartControl != null)
			{
				if (ChartControl.ChartTraderEnabled && ChartControl.ChartTraderVisible)
				{
					acDbg("accountChanged, ChartTrader is enabled and visible");
					
					try
					{
						ctrAccount = (ComboBox)ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Controls["cboAccount"];
						acDbg("ctrAccount " + ctrAccount);
						if (ctrAccount != null)
						{
							ctrSelectedAccount = (Account) ctrAccount.SelectedItem;
							acDbg("ctrSelectedAccount " + ctrSelectedAccount);
							if (ctrSelectedAccount != null)
							{
								mySelectedAccount = ctrSelectedAccount.Name.ToString();
								acDbg("mySelectedAccount " + mySelectedAccount);
								if (mySelectedAccount != "")
								{
									acDbg("accountName was " + accountName + " and now " + mySelectedAccount);
									accountName = mySelectedAccount;	// override ChartMinder Executions account
									
									connectMyAccount("ChartTrader");
								}
							}
						}
					}
					catch { acDbg("failed getting a/c change"); }
					
					acDbg("out accountChanged");
				}
			}
		}
		
		
		
		private void attachToChartTrader ()
		{
			acDbg("attachToChartTrader CC " + ChartControl);
			
			if (ChartControl != null)
			{
				if (ChartControl.ChartTraderEnabled && ChartControl.ChartTraderVisible)
				{
					acDbg("ChartTrader enabled and visible");
					
					try
					{
						ctrAccount = (ComboBox)ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Controls["cboAccount"];
						acDbg("ctrAccount " + ctrAccount);
						if (ctrAccount != null)
						{
							ctrSelectedAccount = (Account) ctrAccount.SelectedItem;
							acDbg("ctrSelectedAccount " + ctrSelectedAccount);
							if (ctrSelectedAccount != null)
							{
								ctrAccount.SelectedValueChanged += new EventHandler(accountChanged);
								mySelectedAccount = ctrSelectedAccount.Name.ToString();
								acDbg("mySelectedAccount " + mySelectedAccount);
								if (mySelectedAccount != "")
								{
									acDbg("accountName was " + accountName + " now " + mySelectedAccount);
									accountName = mySelectedAccount;	// override ChartMinder Executions account
									
									connectMyAccount("ChartTrader");
								}
							}
						}
					}
					catch { acDbg("attach failed"); }
				}
				else
				{
					acDbg("No ChartTrader");
				}
			}
			
			acDbg("out attach");
		}
So basically, 'attachToChartTrader' sets up an event handler callback to 'accountChanged' and you can access the control's value in there or directly.

If you want the full gory story check out my ChartMinder thread.

Cheers

Travel Well
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #19 (permalink)
 Maza 
Cluj-Napoca Cluj/Romania
 
Experience: Intermediate
Platform: NinjaTrader, MetaTrader 4
Broker: FXCM, Continuum
Trading: Forex, Futures
Posts: 12 since Apr 2013
Thanks Given: 6
Thanks Received: 7


ratfink View Post
 
Code
		private void accountChanged (object sender, EventArgs e)
		{
			if (ChartControl != null)
			{
				if (ChartControl.ChartTraderEnabled && ChartControl.ChartTraderVisible)
				{
					acDbg("accountChanged, ChartTrader is enabled and visible");
					
					try
					{
						ctrAccount = (ComboBox)ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Controls["cboAccount"];
						acDbg("ctrAccount " + ctrAccount);
						if (ctrAccount != null)
						{
							ctrSelectedAccount = (Account) ctrAccount.SelectedItem;
							acDbg("ctrSelectedAccount " + ctrSelectedAccount);
							if (ctrSelectedAccount != null)
							{
								mySelectedAccount = ctrSelectedAccount.Name.ToString();
								acDbg("mySelectedAccount " + mySelectedAccount);
								if (mySelectedAccount != "")
								{
									acDbg("accountName was " + accountName + " and now " + mySelectedAccount);
									accountName = mySelectedAccount;	// override ChartMinder Executions account
									
									connectMyAccount("ChartTrader");
								}
							}
						}
					}
					catch { acDbg("failed getting a/c change"); }
					
					acDbg("out accountChanged");
				}
			}
		}
		
		
		
		private void attachToChartTrader ()
		{
			acDbg("attachToChartTrader CC " + ChartControl);
			
			if (ChartControl != null)
			{
				if (ChartControl.ChartTraderEnabled && ChartControl.ChartTraderVisible)
				{
					acDbg("ChartTrader enabled and visible");
					
					try
					{
						ctrAccount = (ComboBox)ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Controls["cboAccount"];
						acDbg("ctrAccount " + ctrAccount);
						if (ctrAccount != null)
						{
							ctrSelectedAccount = (Account) ctrAccount.SelectedItem;
							acDbg("ctrSelectedAccount " + ctrSelectedAccount);
							if (ctrSelectedAccount != null)
							{
								ctrAccount.SelectedValueChanged += new EventHandler(accountChanged);
								mySelectedAccount = ctrSelectedAccount.Name.ToString();
								acDbg("mySelectedAccount " + mySelectedAccount);
								if (mySelectedAccount != "")
								{
									acDbg("accountName was " + accountName + " now " + mySelectedAccount);
									accountName = mySelectedAccount;	// override ChartMinder Executions account
									
									connectMyAccount("ChartTrader");
								}
							}
						}
					}
					catch { acDbg("attach failed"); }
				}
				else
				{
					acDbg("No ChartTrader");
				}
			}
			
			acDbg("out attach");
		}
So basically, 'attachToChartTrader' sets up an event handler callback to 'accountChanged' and you can access the control's value in there or directly.

If you want the full gory story check out my ChartMinder thread.

Cheers

Ratfink,

I had a look at your "ChartMinder" software and I have to say, you rocked my world!!! I am trying to build something way more rudimentary than what you have there.

I have to thank you for the work that you have put into this indicator and just for the time that you have taken to respond to my posts.

With respect,

Maza.

Reply With Quote
Thanked by:




Last Updated on November 14, 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