NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

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.

Reply
 
Thread Tools Display Modes
Old 01-02-2007, 12:49 PM   #1
MAX
Senior Member
 
Join Date: Sep 2006
Location: Rome, , Italy
Posts: 131
Thanks: 2
Thanked 1 time in 1 post
Post imported post

In my trading system I've buy/sell limit orders and only a stoploss and a takeprofit once the position is established.
So I expect to see only one order to buy or to sell and this is what usually happens on the system. The strange thing is that sometime it appears another order (close position, as you can see in the attachment) that duplicates my entry order without any reason.
What is the close position that is not in the code?

If you need I can send the full code in a private message.
Thanks.

Attached Files
File Type: zip Trouble.zip (53.0 KB, 6 views)
MAX is offline  
Reply With Quote
Old 01-03-2007, 01:23 AM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Post imported post

Max,

Send me privately the code and an image of the strategy dialogue window when applying the strategy to a chart. Also let me know the time frame (10 tick I think) and if this can be reproduced in backtest or only live trading. Thanks.
NinjaTrader_Ray is offline  
Reply With Quote
Old 01-03-2007, 06:55 AM   #3
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Post imported post

Max,

After further review, the strategy is operating as designed. I will add some information to the documentation laterdown the road to better explain this.

For example:

Lets say your strategy is currently long and you have a stop and target working in the market.

Your strategy now generates a sell limit entry order. So you now have three working orders, stop/target to exit long position and a sell limit entry.

A) If the sell limit entry is filled, NT will cancel the stop/target and issue a "CLOSE" order to close the long position.

B) If the stop is filled, NT will cancel the target and leave your pending sell limit entry working

C) If the target is filled, NT will cancel teh stop and leave your pendign sell limit entry working

Hope that makes sense. If you are looking for a different behaviour, please let me know and I can provide some suggestions.

One tip: You do not need to check for market position since the method EnterLongLimit() already does that for you internally. If a long position already exists, this method just returns.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 01-03-2007, 10:37 AM   #4
MAX
Senior Member
 
Join Date: Sep 2006
Location: Rome, , Italy
Posts: 131
Thanks: 2
Thanked 1 time in 1 post
Post imported post

Thanks for the explanation.

Code:
One tip: You do not need to check for market position since the method EnterLongLimit() already does that for you internally. If a long position already exists, this method just returns.
Does this avoid to re-enter on the same bar if the position has been stopped out?

Thanks.
MAX is offline  
Reply With Quote
Old 01-03-2007, 10:47 AM   #5
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Post imported post

Yes it would avoid re-entry on the same bar if your strategy is running with the property "Calculate on bar close = true". If set to false, system is evaluated tick by tick and signals can generate on the same bar.

Additional information: The properties "Entries per direction" and "Entry handling" control the internal logic of the Enter() methods.

Example 1:

Entries per direction = 1
Entry handling = AllEntries

Then EnterLongLimit() will be ignored if a long position already exists or if another entry order is pending.

Example 2:

Entries per direction = 1
Entry handling = UniqueEntries

Then EnterLongLimit() will be ignored if a long position already exists that was entered with the same signal name. So if you call the method twice each with unique signal name, then two entry orders can be generated.


Ray
NinjaTrader_Ray is offline  
Reply With Quote
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


All times are GMT -6. The time now is 10:59 PM.