Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Opening 2 contracts instead of one
Collapse
X
-
Opening 2 contracts instead of one
I have a strategy that open a long position when certain conditions are met, then exit long when certain conditions are met. then open a short position when another conditions are met as well then close short positions on certain conditions. sometimes I am getting that the strategy is closing and selling position twice thus opening 2 contracts instead of one. how can I fix that in the strategy builder so that it always open one contract only? see image and code attached.Tags: None
-
Hello babouin77,
Thanks for your post.
Your strategy is using the same entry and exit conditions, this means that for example, you are placing an EnterLong at the same time as ExitShort.
An important concept to understand is that an Entry method will automatically close any position that is in the opposite direction. For example, if you are long 1 and the strategy places an EnterShort(), the short entry method will see the current 1 long and will immediately place 1 sell contract (called "Close position") to close the long position and then it will issue a 2nd sell order to leave the strategy 1 short. However, when you submit ExitLong() at the same time this method also issues a sell contract leaving you with 2 short contracts.
As it looks like your strategy is intended to be always in, you can just remove the ExitLong(0 and ExitShort() orders.
For reference, please review: https://ninjatrader.com/support/help...d_approach.htmPaul H.NinjaTrader Customer Service
-
but if I do that sometimes not all conditions are met to be short... sometimes it will close the long and not be in a trade because not all conditions are met to enter the short position. is there any other way to mitigate this? for example in the image attached the long position was closed but the short position was not opened because not ALL conditions are met... any help is appreciated.
Comment
-
Hello babouin77,
Thanks for your replies.
I was mistaken when I reviewed the strategy, your exit conditions are not exactly the same as your entry condition. So when an ExitShort or ExitLong are called this would not occur on every trade so the issue would only occur when the entry conditions are met along with the singular exit condition.
Another approach here would be to add an entry condition that checks to see that the market position is flat, so you only enter from a flat position. This would prevent making an entry while you are in position and would prevent the unintended double order. Here is a link to the help guide that shows creating a check of the market position in the startegy builder: https://ninjatrader.com/support/help...ionComparisonsPaul H.NinjaTrader Customer Service
Comment
-
but i noticed that it also not opening a new entry if the conditions are met... so i had a long, and it happened the conditions to close the long and open a short were met but it just closed the long but never opened the short using this method. would it be a better way to create a different condition to close the long than to open a short? because this way it is not doing the trade when it should
Comment
-
Hello babouin77,
Thanks for your post.
Now that you know that issuing an Exit order at the same time as an Entry order can cause a double order, you will need to figure what logic you want to ensure that that situation does not occur. Certainly checking for a flat position before entering prevents the double order error. Creating different exit conditions may help.
Paul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Vern10, Today, 10:51 AM
|
1 response
14 views
0 likes
|
Last Post
|
||
Started by Uhumm, Today, 11:18 AM
|
3 responses
28 views
0 likes
|
Last Post
|
||
Started by Net_Trader, 03-15-2023, 03:17 PM
|
14 responses
153 views
0 likes
|
Last Post
![]() |
||
Started by HalTech, Today, 02:11 PM
|
1 response
7 views
0 likes
|
Last Post
|
||
Started by rafaelcoisa, 03-23-2023, 03:18 PM
|
2 responses
22 views
0 likes
|
Last Post
![]()
by rafaelcoisa
Today, 02:16 PM
|
Comment