Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,403 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    94 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    7 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    158 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    8 views
    0 likes
    Last Post Belfortbucks  
    Working...
    X