I use this to check for open positions in Account 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.
The following 2 users say Thank You to monpere for this post:
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...
Please use the Brokers section of the forum for this question, not this thread which is for NinjaTrader "Manual entry, automated exit".
Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.
Need help? 1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first. 2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses. 3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make. 4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance. 5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers. 6) Help using the forum? Watch this video to learn general tips on using the site.
If you want to support our community, become an Elite Member.
@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!
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.
The following user says Thank You to monpere for this post:
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.
The following user says Thank You to MWinfrey for this post: