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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    51 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    142 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    160 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    96 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    275 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X