Could somebody PLEASE tell me what's going on and how to fix it please!? Thank you very VERY much! God bless you!!!
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Weird orders I didn't place.
Collapse
X
-
Weird orders I didn't place.
I wrote a simple strategy with StopLoss and ProfitTarget. But when I run it in the chart, I found out it sometimes close my position prematurely with a Close position which I absolutely didn't put in my code!!!
Could somebody PLEASE tell me what's going on and how to fix it please!? Thank you very VERY much! God bless you!!!Tags: None
-
Dear Paul,
Thank you very very much for you help!
Below is the screen shot of the order and my source code.
The strategy is the basic Forex strategy, where you place an OCO order at the opening of the market and set ProfitTarget and StopLoss accordingly. But it close my order prematurely with a Close position which I had circled.
Please tell me why did that happen and how do I fix it. Thank you very VERY much! God bless you!!!
Snap Shot
Source CodeLast edited by YoutingChu; 07-30-2018, 06:56 AM.
Comment
-
Hello YoutingChu,
Thanks for your reply.
It looks like you are using EnterLong or EnterShort to place orders. These order methods will detect any open positions and will issue closing orders. For example, if the strategy was long one contract and the strategy issues one short order, EnterShort() would issue one sell to "close position" then enter a second sell to leave your strategy in the desired direction (in this case short 1).
If you do not want this to happen then in your order entry block you may want to test to see if you are not flat, for example:
if (Position.MarketPosition != MarketPosition.Flat)
{
// if not flat do something here
}Paul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Jon17, Today, 04:33 PM
|
0 responses
1 view
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
6 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
||
Started by timmbbo, Today, 08:59 AM
|
2 responses
10 views
0 likes
|
Last Post
by bltdavid
Today, 04:10 PM
|
||
Started by alifarahani, Today, 09:40 AM
|
6 responses
41 views
0 likes
|
Last Post
by alifarahani
Today, 03:18 PM
|
||
Started by Waxavi, Today, 02:10 AM
|
1 response
21 views
0 likes
|
Last Post Today, 03:03 PM |
Comment