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

Strategy Builder Indicator Stop Loss Help

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

    Strategy Builder Indicator Stop Loss Help

    Hello, I've been testing several strategies using the Strategy Builder, and I'm having an issue attaching a stop loss to an indicator.

    I'm trying to do the following:

    If all condition are met, go long.
    Set stop loss at the 50sma.

    Here the command from strategy builder:
    SetStopLoss("", CalculationMode.Price, SMA(Close, 50)[0], false);

    When I run a strategy analyzer or try to enable this strategy on a chart no results pop up, it's as if the strategy has never run.

    If I remove this line the strategy runs fine, it just bounces back and forth between the Long and Short conditions.

    Any Hints? Or can you not attach an indicator using Strategy Builder?
    Thanks.
    Mark.

    #2
    Hello Mark@NightOwlTrading,

    Thanks for your post and welcome to the NinjaTrader forums.

    In the strategy builder, you can only use static profit and stop targets, for example CalculationMode.Ticks, 20. The set methods, in the strategy builder, are placed in the State.Configure section of OnStateChange() which would limit changes to what could be set at run time. For example as a user input you can set the number of ticks to use (for stop or for profit or both) and when the strategy is run it would use that value from the UI and would apply those values to all trades made.

    Alternatively, you could add condition sets that check to see if you are long or short and then place an appropriate exit limit order at the dynamically changing SMA, however in doing so you would not be able to use the set methods as well as this would cause conflicts with the internal order handling rules here: http://ninjatrader.com/support/helpG...d_approach.htm

    Alternatively, to dynamically use the set methods (which are OCO linked) if you wish to unlock the code, then you can move the SetStopLoss() method into the OnBarUpdate where it can be dynamically assigned per your example. However once unlocked you would not be able to access the strategy through the strategy builder and could only work through the Ninjascript editor.

    References:

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the info. I did exactly what you directed, and my strategy is working great.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by jclose, Today, 09:37 PM
      0 responses
      5 views
      0 likes
      Last Post jclose
      by jclose
       
      Started by WeyldFalcon, 08-07-2020, 06:13 AM
      10 responses
      1,413 views
      0 likes
      Last Post Traderontheroad  
      Started by firefoxforum12, Today, 08:53 PM
      0 responses
      11 views
      0 likes
      Last Post firefoxforum12  
      Started by stafe, Today, 08:34 PM
      0 responses
      11 views
      0 likes
      Last Post stafe
      by stafe
       
      Started by sastrades, 01-31-2024, 10:19 PM
      11 responses
      169 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X