Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetStopLoss + MACD

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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 help

    #2
    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));
    			}

    Comment


      #3
      Wow, very good response, thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      646 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      367 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      569 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X