Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
SetStopLoss + MACD
Collapse
X
-
SetStopLoss + MACD
Hello, I'm developing a strategy where I have a stoploss tick of 50, however, I don't want that to trigger UNLESS the MACD has also crossed over. There have been times where triggers are met, but the MACD doesn't agree. I don't want to adjust my tick size to 50, as I've backtested many resolutions from 20-75 and 50 is the sweet spot. If there is a way I can code the SetTrailSTOP with and/or MACD > AVG or MACD < AVG that would be wonderful. Thanks for the helpTags: None
-
Hello rdavido,
Thank you for your post.
You can set the SetTrailStop() in the OnBarUpdate() method and wait for your conditions, the only thing here is that the Set methods are submitted once the order fills. So if you need to wait for the macd to agree with the exit before you use the trail stop I would recommend not using the Set methods but using the Exit methods.
This means you would need to update the Exit method in OnBarUpdate() when your conditions is true (likely ExitLongStop() or ExitShortStop()) to act as a trailing stop.
For example:
Code:if(Position.MarketPosition == MarketPosition.Long && MACD(12, 26, 9)[0] < MACD(12, 26, 9).Avg[0]) { ExitLongStop(MAX(High, BarsSinceEntry())[0] - (50*TickSize)); }
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
637 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
366 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
107 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
569 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
572 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment