![]() |
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
|
|||||||
| Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
I am using Tradestation8 --> IB and wish to check that *IB* does not have a position before I send an order.
I noticed that the NTMarketposition function uses the TRADESTATION "marketposition" command. That will not return the marketposition for Interactive Brokers ! Is there a command that I can use to get the IB marketposition. Thanks |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
The function calls a method on the NT DLL called marketposition and is not to be confused with the EL reserved word "marketposition". NTMarketPosition will return what you are looking for.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
whilst i havent tried it yet im concerned it will not work, because you have used a TS reserved word which the easylanguage compiler recognises. for example when i open up the function, the "marketposition" command is highlighted in blue - this means that tradestation has automatically recognised it as a built in TS reserved word. |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
No, it works fine. Check out e.g. NTSample strategy.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
ok thanks.
|
|
|
|
|
|
#6 |
|
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
Dierk
I had a problem in testing today with NTmarketposition returning zero, for a position that i held in IB. it was for "IWM" stock symbol. i was using a print statement to verify that NTmarketposition was returning the correct value. it read as: print(date,time,NTmarketposition("IWM","")); the default account was set to be my live IB account which held the position. i am ASSUMING that the account code can be left blank on this call if you are using the default account. the print statement returned the following output: 1060213.001438.00imktpos=-1 -100.00 0.00 (the -100 is the TS strategy). the 0.00 is what NTmarketposition returned one thing to mention: i am not receiving market data into IB for IWM. however placing orders via the NT ATI works 100% OK if no checks are being made with regards to NTmarketposition. can you please let me know if i am doing something wrong or whether perhaps this is a bug in NT ATI thanks |
|
|
|
|
|
#7 |
|
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
apologies, i had the wrong piece of code pasted for that routine. it should have been:
............. NTContracts=NTmarketposition(NTProductCode,""); print(date,time,"imktpos=-1 ",TSContracts,NTContracts); {please note that NTProductCode = "IWM"} |
|
|
|
|
|
#8 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Jonno,
NTMarketPosition does not take the stock symbol as an argument. Not sure if this is causing the issue. print(NTMarketPosition("")); should print out the correct position for the instrument loaded in the TS chart that your strategy is applied to. Ray PS - Forgot to add that you are correct in your understanding of the default account use.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
Ray
ray you are right, i had actually changed the P1 parameter in the NTmarketposition function/DLL to be passed in as a string as opposed to the chart based TS EL symbol retrieve that was being done. sorry i also forgot to mention that! no more surprises i promise. :-) can i request an enhancement that the NTmarketposition function allows you to explicitly pass the product code? I am trying to do symbol substitution, where when i get a signal on the russell via an applied strategy, i am sending orders for IWM. part of this *requires* position checks on IWM which does not seem possible from the ER2 chart. i would think that plenty of users will find it useful to be able to pass the product code to the NTmarketposition function call as opposed to hard coded symbol retrieve. thanks angus |
|
|
|
|
|
#10 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Angus,
Thanks for your suggestion. Will add to list for consideration. Ray
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Actually, the underlying DLL function is implemented with symbol/account name. Its just the NTMarketPosition wrapper function that handles it for convenience.
Open up the NTMarketPosition function in EL and create a new one that takes the symbol name as an input. Ray
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#12 |
|
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
i tried that id did not work. appreciate if u can look at this and let me know if i have done something wrong. if not, can u pls let me know when it will be fixed? i am having to resort to TradeBolt in the meantime.
here is the modified wrapper: { ** Copyright (c) 2005, NinjaTrader LLC ninjatrader@ninjatrader.com } DefineDLLFunc: "NtDirect.dll", int, "MarketPosition", lpstr, lpstr; inputs: Account(string),ProductCode(string); NTMarketPosition = MarketPosition(ProductCode, Account); ------------------------------------------------------------------------------------------------------- here is a little test indicator that i applied to a chart: value1 = NTMarketPosition("IWM",""); {def acct = live account in NT options setup} { it also does not work if i explicitly define my account number as parameter 2 string} print(date,time,symbol," ",value1); --------------------------------------------------------------------------------------------------------- here is the print output: 1060224.001300.00IB:KSH6 0.00 <=== you can see that it is not picking up the IB position that currently exists in my live account 1060224.001300.00IB:KSH6 0.00 1060224.001300.00IB:KSH6 0.00 ---------------------------------------------------------------------------------------------------------- |
|
|
|
|
|
#13 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Is Automated Trading Enabled via the File--> menu?
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#14 |
|
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
|
yes
|
|
|
|
|
|
#15 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
The MarketPosition function will only return information for positions created through the ATI. The ATI does write all position information to a files (See the file interface section) indpendant if they were created through the ATI or not. This might be an alternate approach.
Ray
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|