Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can stop loss be a rule rather than a value?

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

    Can stop loss be a rule rather than a value?

    I'm fairly new to the NinjaTrader8 strategy. I'm starting with a simple one just to learn. So here's my strategy
    Code:
    Long:
    If the MACD line crosses above the Avg. line
    
    
    Short:
    If the MACD line cross below the Avg. line
    
    
    Take profit:
    If the candle moves [I]x[/I] ticks in the long/short direction
    
    
    Stop loss:
    If the MACD line crosses the opposite direction
    So I know how to set a certain point/ticks for the stop loss. But here I want the active order to stop only when the MACD line and Avg. line crosses the opposite direction. Do I need to manually set a rule for this, or is it automatically stopped when the lines cross?

    If it is automatic, then can I NOT set the stop loss? Can I set only take profit?

    #2
    Hello hasana1,

    Thanks for your post.

    I understand that you would like to create crossover conditions in your script to enter a long or short position and have a stop loss and profit target placed 'x' number of ticks from the entry order.

    You could use a 'Cross above' or 'Cross below' comparison to create crossover conditions in your strategy.

    Note that crossover conditions require a look-back period of 1 or more and a value of 0 cannot be used. Say the look-back is set to 1, this means that if the crossover condition occurs in the last 1 bar, the condition is true. If the look-back period is set to 5, this would check if the crossover occurs on the previous 5 bars.

    If you would like to compare is the MACD plot line is above or below the Avg plot line on the currently forming bar, you would need to use a 'Greater' or 'Less' comparison.

    See this help guide page for information about how to create crossover conditions in the Strategy Builder: https://ninjatrader.com/support/help...sOverCondition

    You could use the Stops and Targets screen of the Strategy Builder to create a stop loss and profit target order in your strategy. You could set the stop loss or profit target to be placed a set number of ticks from the entry order.

    See this help guide page for more information about using the Stops and Targets screen: https://ninjatrader.com/support/help...dTargetsScreen

    Also, you could find a publicly available training video, Strategy Builder 301, linked below which you might find helpful.

    Strategy Builder 301 — https://www.youtube.com/watch?v=_KQF2Sv27oE&t=13s

    Let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    559 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    546 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X