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 NullPointStrategies, Today, 05:17 AM
|
0 responses
50 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
126 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
69 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment