LE=EnterLongStop(lprice,"LE"); SE=EnterShortStop(sprice,"SE");
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Simultaneous orders
Collapse
X
-
Simultaneous orders
I am trying to place a simultaneous buy and sell order, but it is ignoring the second order. My code looks like this. Am I doing something wrong?
Code:Tags: None
-
I was about to ask the same question... how is it if you don't have an ATM selected in chart trader that you can have both a Long Stop order and a Short Stop order active. You can also have 2 separate strategies active - one placing a Long Stop order and the other placing a Short Stop order.
I'm not nit picking deliberately - I would genuinely like to have a Longstop and shortstop order active at the same time from within the same strategy -- when one gets filled the other gets cancelled.
If one strategy fills an order can another active strategy on the same instrument see that it has been filled ?
Comment
-
Chart Trader is different. Each group of orders are managed independently of each other. From a single NinjaScript strategy you cannot place simultaneous entry orders in opposite directions for the same instrument. If you read the TraceOrders output when you try to do this it will tell you to review the Internal Order Handling Rules.
You can review them here: http://www.ninjatrader-support.com/H...verview36.html
Cross-strategy communication is not supported.Josh P.NinjaTrader Customer Service
Comment
-
Quick response - thanks. Had a quick read of the link.Originally posted by NinjaTrader_Josh View Post
Cross-strategy communication is not supported.
Can a strategy tell if an instrument has got an active order OR if there is a position in the market ?
My requirement is very simple - have a longstop strategy and a shortstop strategy - if one gets filled the other cancels itself when it sees that there is a position in the market.
Comment
-
Unfortunately, no, a strategy only knows what is calculated based off of the strategy. What you want to do requires cross-strategy communication. It is possible through more advanced C#. You can search the forums for other users who have tried, but this is an endeavor we cannot offer you any support on.Josh P.NinjaTrader Customer Service
Comment
-
scottyboy,Originally posted by scottyboy View Post...If one strategy fills an order can another active strategy on the same instrument see that it has been filled ?...
Cross-strategy communication could be achieved by implementing static data members/methods in the strategy class or designing a strategy base class containing the static data. When multiple strategies are instantiated, they all share the static elements.
Regards
Ralph
Comment
-
Thanks Ralph - I will have to look into that but I suspect it's going to make me scratch my head a bit. I found a post that shows how to call up StreamWriter and create a text file -- this quick and dirty method will allow me to easily flag up what the other strategy is doing.
If you get a quiet moment in the next few days I would appreciate you pointing me in the right direction with...
implementing static data members/methods in the strategy class or designing a strategy base class containing the static data.
Off to bed for me - getting very late.
Comment
-
Hi scottyboy,
in reference to the link you mentioned, here is an example how to code a similar concept with a static data flag:
Define a static strategy variable:
private static longPosFlag;
If your entry conditions are met:
if (!longPosFlag) {
EnterLong...
longPosFlag = true;
}
If your exit conditions are met:
ExitLong...
longPosFlag = false;
Regards
Ralph
Comment
-
Hello Ralph, I tried this but when I ran the same strategy twice longPosFlag did not seem to be affected by the value in the other strategy.
I had to use private static bool longPosFlag;
I put it in #region Variables
I suspect I have mis-understood what you intended.
Thanks for your help with this.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
558 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
545 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment