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)
I use this to check for open positions in Account[0] because I am generally connected to only one account, but if you generally are connected to multiple accounts, you would have to loop through the NinjaTrader.Cbi.Globals.Accounts[x] array as well.
//### Open Positions
if ( NinjaTrader.Cbi.Globals.Accounts.Count > 0 && NinjaTrader.Cbi.Globals.Accounts[0].Positions.Count > 0 ) {
for (int i=0; i < NinjaTrader.Cbi.Globals.Accounts[0].Positions.Count; i++ ) {
if ( NinjaTrader.Cbi.Globals.Accounts[0].Positions[i].Instrument.FullName == Instrument.FullName ) {
Print(NinjaTrader.Cbi.Globals.Accounts[0].Name +" Position " +(i+1) +". "
+NinjaTrader.Cbi.Globals.Accounts[0].Positions[i].Instrument.FullName +" "
+NinjaTrader.Cbi.Globals.Accounts[0].Positions[i].MarketPosition +" "
+NinjaTrader.Cbi.Globals.Accounts[0].Positions[i].Quantity +" "
+"@"+NinjaTrader.Cbi.Globals.Accounts[0].Positions[i].AvgPrice+" "
);
}
}
}
I use this to check for open positions in Account[0] because I am generally connected to only one account, but if you generally are connected to multiple accounts, you would have to loop through the NinjaTrader.Cbi.Globals.Accounts[x] array as well.
Thank you @monpere...that got me off top dead center.
There are all sorts of issues with MB Trading if your want to do anything innovative. Their systems and infrastructure are just antiquated. They have to shutdown after market everyday for maintenance, their responses to order executions and modifications are slow, they have regular unscheduled outages, the market will go through your orders by several ticks and you will not get fills. The only redeeming things I found were are that you can trade micro lots, and they pay you when you provide liquidity with limit orders. That's been my experience with them.
You can do most the things you want with various other brokers. I personally use Interactive Brokers and Mirus Futures to reliably do some of these things.
Don't have enough capital to open an IB account. What other FX brokers are reliable that I can work with? I looked for quite a while and MB seemed the best one for the $2k I have to start with.
Since I am having so much trouble figuring out how to automate exits, what do you all think of Managed Forex Accounts? I know that you all prefer to do your own trading. I feel the same. But at this point, am not avail. to watch the account all night long...
Don't have enough capital to open an IB account. What other FX brokers are reliable that I can work with? I looked for quite a while and MB seemed the best one for the $2k I have to start with.
Please use the Brokers section of the forum for this question, not this thread which is for NinjaTrader "Manual entry, automated exit".
//### Open Positions
if ( NinjaTrader.Cbi.Globals.Accounts.Count > 0 && NinjaTrader.Cbi.Globals.Accounts[0].Positions.Count > 0 ) {
for (int i=0; i < NinjaTrader.Cbi.Globals.Accounts[0].Positions.Count; i++ ) {
if ( NinjaTrader.Cbi.Globals.Accounts[0].Positions[i].Instrument.FullName == Instrument.FullName ) {
Print(NinjaTrader.Cbi.Globals.Accounts[0].Name +" Position " +(i+1) +". "
+NinjaTrader.Cbi.Globals.Accounts[0].Positions[i].Instrument.FullName +" "
+NinjaTrader.Cbi.Globals.Accounts[0].Positions[i].MarketPosition +" "
+NinjaTrader.Cbi.Globals.Accounts[0].Positions[i].Quantity +" "
+"@"+NinjaTrader.Cbi.Globals.Accounts[0].Positions[i].AvgPrice+" "
);
}
}
}
@monpere using the construct you provided is very helpful. I added a condition to exit a trade and then added Strategy.ExitLong() if the exit condition is met. Unfortunately, I get an error "Object reference not set to an instance of an object." I loop through the accounts and positions arrays to get the right ones but yet I get that error. Have I given enough for you to know what might be happening?
Could you help me with this risk control? I have created an strategy with two targets for the Ninja Trader ATM DOM, both of them with 8ticks of inicial stop, then I put a trailing stop with frequency on ONE. But what Im looking for is that, when the trade goes bad, itch tick it goes back, the target also goes back one tick as the profit. Do you get it? An example: My stop is 8, and my target is also on 8, but if it goes bad, ich tick it goes, the stop will be 7, the target 7... Thats it, waiting for answers. Thank you!
Could you help me with this risk control? I have created an strategy with two targets for the Ninja Trader ATM DOM, both of them with 8ticks of inicial stop, then I put a trailing stop with frequency on ONE. But what Im looking for is that, when the trade goes bad, itch tick it goes back, the target also goes back one tick as the profit. Do you get it? An example: My stop is 8, and my target is also on 8, but if it goes bad, ich tick it goes, the stop will be 7, the target 7... Thats it, waiting for answers. Thank you!
I don't do any trade management within the indicator, and I am not a fan of instantiating a strategy from within an indicator. All my trade management is done in a stand alone strategy started in the strategy tab.
I wrote an indicator that is intended to automatically exit trades while still being able to use the ChartTrader to enter trades. So in other words, Manual Entry --- Automated Exit.
This code does not have buttons and runs just like any other indicator. It's very basic as you can tell by looking at the code. However, there is a problem that I need help with. The ExitShort or ExitLong causes an error "Object reference not set to an instance of an object."
I'm not sure what object reference it's referring to and have spent a lot of time trying to figure it out. So, I thought I'd present it here to see if anyone else can figure it out.
Once this problem is solved I can move on to making this indicator more functional...I hope.
Thanks,
Mike
Elite Membership required to download: ManageTrades.cs