Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Reverse Trade When Stop Hit
Collapse
X
-
Reverse Trade When Stop Hit
I'm using Strategy Builder. The stop is a set of conditions, not a hard stop. When the stop is hit, I would like the strategy to initiate a new position in the opposite direction with a different number of contracts, Profit Target and Stop Loss. Can you give me some ideas as to how I can set this up. Thank you.Tags: None
-
Hello Fran888,
Thank you for your post.
To reverse based specifically on the fill of the stop loss is not possible in the Strategy Builder as it would require manual coding. You would need to unlock the script and code the logic by hand.
For the detection of an order execution, you can look for the order name of your stop loss in OnExecutionUpdate().
Here is an example of code that detects and prints what the order is:
You can use the above code to test the detection out as it will send the print statements to the output window (New > NinjaScript Output).Code:protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time) { if (execution.Name == "Stop loss") Print(string.Format("{0} - Stop loss was filled", execution.Time)); }
With the above code you can then add logic to your code to then enter an opposite direction order from within OnExecutionUpdate() if the filled order was a stop loss.
Please let us know if we may be of further assistance to you.
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
87 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
132 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
65 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
118 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
67 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment