Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help Adding Exit Condition Based on Moving Average

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

    Help Adding Exit Condition Based on Moving Average

    I’ve developed a NinjaTrader strategy that successfully handles entry conditions for futures trading. However, I would like to enhance it by adding an exit condition based on the color change of a moving average, which reflects market direction.

    Here’s what I’m looking for:

    - **For Long Trades**: Exit the position when the moving average changes from green (bullish) to red (bearish).
    - **For Short Trades**: Exit the position when the moving average changes from red (bearish) to green (bullish).

    I’m using a colored moving average to visually represent the market trend. I would like the strategy to automatically close the trade once the color indicates a trend reversal. I assume I’ll need to reference the moving average’s color property within the strategy code to trigger the exit, but I’m not sure how to do this efficiently.

    Could someone assist me in implementing this logic or point me to relevant resources that would help integrate this exit condition into my existing strategy?
    Thank you!


    #2
    Hello NasdaqAnalytica,

    You would need to come up with a price condition for that, colors cannot be used for strategy signals.

    Once you have identified the values you want to use for the exit condition based on the indicators price you could add new sets to submit exit orders based on those conditions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    134 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X