Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
bypass Onstartup code when no connection
Updated January 16, 2016
Top Posters
looks_one
vantojo
with 6 posts (0 thanks)
looks_two
choke35
with 2 posts (0 thanks)
looks_3
Quick Summary
with 1 posts (0 thanks)
looks_4
ratfink
with 1 posts (3 thanks)
trending_up
1,962 views
thumb_up
3 thanks given
group
3 followers
forum
9 posts
attach_file
0 attachments
bypass Onstartup code when no connection
January 15th, 2016, 01:00 PM
Vilcabamba, Ecuador
Experience: Intermediate
Platform: Ninja
Trading: NQ, UB
Posts: 204 since Jul 2012
Sometimes I don't automatically connect to a provider when Ninja starts up.
But I still have workspaces that open charts with indicators.
In this case I would like to bypass some code in OnStartup. (when there is no connection, or ninja starts with no connection)
Any ideas?
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
January 15th, 2016, 01:04 PM
Vilcabamba, Ecuador
Experience: Intermediate
Platform: Ninja
Trading: NQ, UB
Posts: 204 since Jul 2012
January 15th, 2016, 01:23 PM
Germany
Experience: Intermediate
Platform: Other
Trading: ES, YM, 6E
Posts: 2,668 since Feb 2013
Thanks Given: 5,101
Thanks Received: 6,558
See the OnConnectionStatus() method.
You can switch your code on/off accordingly.
January 15th, 2016, 02:40 PM
Vilcabamba, Ecuador
Experience: Intermediate
Platform: Ninja
Trading: NQ, UB
Posts: 204 since Jul 2012
OK, it looks like it should work, but I get this compile message... (it is in a working indicator that otherwise compiles normally)
'NinjaTrader .Indicator.AANews.OnConnectionStatus(NinjaTrader.Cbi.ConnectionStatus, NinjaTrader.Cbi.ConnectionStatus)': no suitable method found to override
===============================================================================
bool connected = false;
#region OnConnectionStatus
protected override void OnConnectionStatus(ConnectionStatus orderStatus, ConnectionStatus priceStatus)
{
if (priceStatus = ConnectionStatus.Connected)
connected = true;
else
connected = false;
}
#endregion
===========================================================================
not finding much on the web for this error
January 15th, 2016, 03:05 PM
Germany
Experience: Intermediate
Platform: Other
Trading: ES, YM, 6E
Posts: 2,668 since Feb 2013
Thanks Given: 5,101
Thanks Received: 6,558
January 15th, 2016, 04:14 PM
Vilcabamba, Ecuador
Experience: Intermediate
Platform: Ninja
Trading: NQ, UB
Posts: 204 since Jul 2012
Ok, then that method won't work for me because these are chart indicators not used in any strategy....
any other ideas?
January 15th, 2016, 05:27 PM
Vilcabamba, Ecuador
Experience: Intermediate
Platform: Ninja
Trading: NQ, UB
Posts: 204 since Jul 2012
this is not instantiated in OnStartUp when there is no connection....
Bars.MarketData.Connection.Options.Provider
if I check it for null, it tells me it is a non-nullable field....
how can I tell if it is instantiated (I'm not a C# guru...)
If it is not instantiated then I know there is no connection and I can bypass the code I want...
Thanks!
January 15th, 2016, 05:37 PM
Vilcabamba, Ecuador
Experience: Intermediate
Platform: Ninja
Trading: NQ, UB
Posts: 204 since Jul 2012
OK, it can be compared to null....
but it is not instantiated so I get a run error "Object reference not set to an instance of an object" when comparing (==) to null
ideas?
January 16th, 2016, 02:25 AM
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
vantojo
OK, it looks like it should work, but I get this compile message... (it is in a working indicator that otherwise compiles normally)
'
NinjaTrader .Indicator.AANews.OnConnectionStatus(NinjaTrader.Cbi.ConnectionStatus, NinjaTrader.Cbi.ConnectionStatus)': no suitable method found to override
In an indicator you have to attach your own callback in OnStartup to get access to the same functionality:
Code
NinjaTrader.Cbi.Globals.Connections.ConnectionStatus += new ConnectionStatusEventHandler(OnConnection);
Check the 'private void OnConnection' code in the 'Accounts and Executions' section of ChartMinder if needed, but a cut down example is:
Code
private void OnConnection (object sender, ConnectionStatusEventArgs e)
{
if (e.Status == ConnectionStatus.Connecting)
{
}
else if (e.Status == ConnectionStatus.Connected)
{
}
else if (e.Status == ConnectionStatus.ConnectionLost || e.Status == ConnectionStatus.Disconnected)
{
}
}
You also need to disconnect the handler in OnTermination:
Code
NinjaTrader.Cbi.Globals.Connections.ConnectionStatus -= new ConnectionStatusEventHandler(OnConnection);
Cheers
Last Updated on January 16, 2016