below I put the code
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
reverse using unmanaged mode
Collapse
X
-
reverse using unmanaged mode
Good day, help me please, I wrote a simple strategy in learning mode, unmanaged, but still can't figure out how to do a position reversal from the initial point of entry if the stop loss gets triggered, could you help me?
below I put the codeTags: None
-
Use the OnExecution() handler to determine ff the Stop Loss was the executed trade, then enter another trade in the desired direction?Originally posted by Papercut110 View PostGood day, help me please, I wrote a simple strategy in learning mode, unmanaged, but still can't figure out how to do a position reversal from the initial point of entry if the stop loss gets triggered, could you help me?
below I put the code
-
I understand you correctly, it should look something like this?
if (stopOrder != null && stopOrder == execution.Order)
{
}
while on the other hand the script needs to understand what the position was closed by stop - long or short...
Comment
-
Pretty much, provided your exit order (stop loss) is called stopOrder.Originally posted by Papercut110 View PostI understand you correctly, it should look something like this?
if (stopOrder != null && stopOrder == execution.Order)
{
}
while on the other hand the script needs to understand what the position was closed by stop - long or short...

Your question kind of implied that your Stop Loss being hit would be to take the position flat, which is why I stopped where I did. Otherwise, you would have to query the Position for its size, and calculate the necessary size of the reversal order to put you in the position that you want to be in. The Position object holds all the data that you need to determine your existing market posture, at any time.
Comment
-
I solved this problem by naming the entry order in a special way.Originally posted by Papercut110 View Postwhile on the other hand the script needs to understand what the position was closed by stop - long or short...

For entry orders:
I prefix CurrentBar with an 'L' or 'S', depending on direction.
(Example: L2345)
For stop orders, I add suffix "stp" to the entry order name.
(Example: L3245stp)
For target orders, I add suffix "tgt" to the entry order name.
(Example: L3245tgt)
OK, so when dealing with your stop order, just look at the stopOrder.Name field and check the first letter, then you'll know the direction.
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 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
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
574 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment