![]() |
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 |
|
Senior Member
Join Date: Sep 2006
Location: Rome, , Italy
Posts: 131
Thanks: 2
Thanked 1 time in 1 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. |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Sep 2006
Location: Rome, , Italy
Posts: 131
Thanks: 2
Thanked 1 time in 1 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. Thanks. |
|
|
|
|
|
#5 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|