PDA

View Full Version : Entering too many contracts with Tradestation order


sgordon77
01-19-2009, 09:28 PM
I have something like the following.

VARS: entryP(0), ccN(0), eFlag(true);

if NTMarketPosition("") = 0 then begin
entryP = Close;
eFlag = true;
NTCancel("LL");
NTCancel("LPT");
NTCancel("LStop");
end;

// I used this code b/c a thread on Ninja's website said NTMarketPosition is unreliable on partial fills.
ccN = NTFilled("LEn") + NTFilled("LL");

NTBuyMarket("LEn", 1);

if NTMarketPosition("") > 0 then begin
if eFlag then
NTBuyLimit("LL", 3, entryP-10);
eFlag = false;

if ccN >= 4 then
NTCancel("LL");

NTSellLimit("LPT", ccN, entryP + 10);
NTSellStop("LStop", ccN, entryP - 20);
end;

In this case, sometimes it will enter many more than 3 contracts on the add on. It has entered as many a 15 contracts. Could this be a Ninja setting, or am I overlooking something else?

Thanks for your help!

sgordon77
01-19-2009, 10:11 PM
This is all occurring in simulation mode.

NinjaTrader_Josh
01-20-2009, 07:40 AM
You need to debug your code.

if NTMarketPosition("") > 0 then begin
if eFlag then
NTBuyLimit("LL", 3, entryP-10);
eFlag = false;

See why your eFlag is not stopping the additional NTBuyLimit()s.

sgordon77
01-20-2009, 08:53 AM
Josh,

Thanks for your response. I don't set eFlag anywhere else. Also, it will fill the order multiple times on each bar. When I look in the log, it is only buying one contract at a time eventhough the order specifies 3.

NinjaTrader_Bertrand
01-20-2009, 09:14 AM
Hi sgordon77, do you happen to use IntraBar order generation in TradeStation? Does the same happen with the provided NTSample strategy?

sgordon77
01-20-2009, 12:01 PM
No, I do not use intrabar execution in Tradestation. I can try the NTSample strategy, but I have not yet. As I recall, this strategy does not do multiple entries is the same direction, could this be part of the problem?

sgordon77
01-20-2009, 12:04 PM
This occurred again last night. The strategy was supposed to buy 3 contracts as an "add on", but it bought 4. I am running the exact same thing in TS, and it work fine (I do NOT have the email connection to Ninja setup). I have the TS orders and the Ninja orders in the same strategy, but I don't see how that could be realted.

For example:
Buy next bar at market;
if NTConnected("") then
NTBuyMarket("LEn", 1);

sgordon77
01-20-2009, 12:08 PM
Also, this same behavior also occurred when I was using an ATM strategy and NTCommand to place/modify the orders.

NinjaTrader_Bertrand
01-20-2009, 12:17 PM
Hi sgordon77, are you testing this with a flat Sim 101 account position in NinjaTrader?

Please attach your full TS test code so I can run this on my end here. Thanks!

sgordon77
01-20-2009, 12:52 PM
Yes, I am. If the strategy has a position, I match it using the DOM.

I will send you the code in a few hours in a PM.

NinjaTrader_Bertrand
01-20-2009, 12:58 PM
Okay thanks will look out for it.

samuelhogg
02-01-2009, 02:50 PM
I have a quick question and I didn't want to start a new thread for what will probably be a simple answer.

If I use Tradestation with Forex.com and Rosenthal Collins Group which are both Ninjatrader supported brokerage partners, will I be able to trade on those accounts using Ninjatrader?

Many thanks

NinjaTrader_Ben
02-02-2009, 01:51 AM
Hello,

If the broker uses one of these data feeds, you can trade with it if you have a live license:
http://www.ninjatrader-support.com/HelpGuideV6/HistoricalData.html

However, for TradeStation, you will not have access to live trading. This link will help:
http://www.ninjatrader.com/webnew/support_TradeStation.htm