NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 07-24-2012, 01:47 AM   #1
jbesada
Member
 
Join Date: May 2012
Posts: 73
Thanks: 3
Thanked 0 times in 0 posts
Default Overall Market Position

Hello,

I am using Positions[0].MarketPosition to check the current Market Position for the first instrument, but this value checks only current strategy position and not the real one.
So, after a restart and if a position is open (for whatever reason) it doesn’t check the real Market Position.
So now, I have a position opened, I can see it on Positions window but my strategy cannot take proper actions. Is there any other way to check the overall Market Position?

Thank you
jbesada is offline  
Reply With Quote
Old 07-24-2012, 02:31 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Hi jbesada, that would be unfortunately expected - the strategy script can only access the individual strategy market position - it would not be supported to access the position of the account the script would run on, this is on our feedback list for consideration though - I've added your vote in here as well.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 08-27-2012, 06:03 PM   #3
RunnrX
Member
 
Join Date: Jul 2012
Posts: 56
Thanks: 13
Thanked 8 times in 8 posts
Default

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
Hi jbesada, that would be unfortunately expected - the strategy script can only access the individual strategy market position - it would not be supported to access the position of the account the script would run on, this is on our feedback list for consideration though - I've added your vote in here as well.

This is surprising! I really like using ninjatrader for backtesting but I find this issue to be very dangerous, and at the least very inconveniencing. I used to program in other platforms and there were ways to get info on all open orders in the account that existed before the strategy was started, and to pull their OrderID and manipulate them (close them, assume general control and monitor them).

Please, I would urge the developers to create a way to check from the strategy if the account is holding any position at all, and to control those positions. I am using a multiple daily bar strategy, and I won't want my position wiped out if the computer accidentally powers off, or I accidentally hit Reload Ninjascript on the chart window.

Thanks
RunnrX is offline  
Reply With Quote
Old 08-27-2012, 10:22 PM   #4
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,794
Thanks: 160
Thanked 568 times in 559 posts
Default

Thank you for your feedback and suggestions. We value your opinions and they will be considered in our feature discussion for a future NinjaTrader release.

I have documented this case as a feature request and as soon as we have a tracking ID for this particular request, we will update this thread.

Please let me know if there is anything else I can do for you.
NinjaTrader_Matthew is offline  
Reply With Quote
Old 08-28-2012, 01:09 AM   #5
jbesada
Member
 
Join Date: May 2012
Posts: 73
Thanks: 3
Thanked 0 times in 0 posts
Default

100% agree with RunnrX. I think it is completely necessary have control of positions of the real account.

Thank you
jbesada is offline  
Reply With Quote
Old 08-28-2012, 06:52 PM   #6
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,794
Thanks: 160
Thanked 568 times in 559 posts
Default

Thank you for your suggestion for the improvement of NinjaTrader. I have submitted it into our tracking system with the unique ID #776.
NinjaTrader_Matthew is offline  
Reply With Quote
Old 08-28-2012, 10:09 PM   #7
RunnrX
Member
 
Join Date: Jul 2012
Posts: 56
Thanks: 13
Thanked 8 times in 8 posts
Default

Quote:
Originally Posted by NinjaTrader_Matthew View Post
Thank you for your suggestion for the improvement of NinjaTrader. I have submitted it into our tracking system with the unique ID #776.

Thank you! If this feature gets added in to the next version, or just even a minor patch, I would be your friend for life.

With the way things are, I can only rely on the strategies I code to be backtest examples, and to only run short term intraday trading systems.

For a daily bar, multi-day system I just spent 25 hours coding, it won't work with Ninjatrader automatically because every time the computer gets turned off at night the strategy will lose track of the fact that there was a working buy stop order that needs to be updated with a lower stop price on each day's close, or it will forget that there's an already open position to monitor for exit signals, and the open position will just run wild and unattended to.. so I would literally have to do all the trading manually in this case after all, with at least the help of the strategy showing me where it would enter and exit, even if it's not actually executing the orders anymore.

It's been a while since I programmed in metatrader 4, or this ForexTester backtesting program, but I was sure that they had a coding method that could detect all open orders in the account and get their information, something like this (rough code example, not correct syntax, just making up method names from memory from 2 yrs ago, etc)


int NumberOfOpenOrders = GetTotalOrders() // returns an integer of how many open orders exist in your account

for (i=0; i < NumberOfOpenOrders; i++)
Array[i] = GetOrderID(i);

OrderIWantToClose = GetOrderType(Array[3])

So the strategy could get the IDs of all existing open orders that were opened before the strategy started and assume control over managing and closing them.

Or, something like this was also possible

private IOrder EntryOrder = GetOrderID(0); if there was only one open order at the time


I know the code I wrote probably has logic errors, but you know what I'm trying to say..

if that could be added to NinjaTrader, then it would be a truly automated trading platform that I could use to swing trade stocks for days and weeks with peace of mind, and like I said, I would be your friend forever

Thanks for reading this
RunnrX is offline  
Reply With Quote
The following user says thank you to RunnrX for this post:
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Market depth position/market maker with kinetick diff24rac SuperDOM and other Order Entry Windows 6 08-04-2011 08:51 AM
Market Position rjngh2005 General Programming 1 06-23-2011 05:02 PM
Position Quantity 0, Market Position Long Camdo Miscellaneous Support 1 12-31-2010 01:05 PM
Automatically enter position on Market Open, Close position on Market Close kevendickenson SuperDOM and other Order Entry Windows 1 04-02-2010 04:30 AM
Market Position value dwil Automated Trading 7 07-13-2006 04:02 AM


All times are GMT -6. The time now is 09:55 PM.