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 cmoran13, 04-16-2026, 01:02 PM
|
0 responses
43 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
25 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|
||
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
163 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
98 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
158 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|

Comment