Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trailing stop won't work, and can't live trade strategy

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

    Trailing stop won't work, and can't live trade strategy

    I am using the ninascript editor to code a simple MA crossover strategy. However I can't seem to get the trailing stop function to work. I wan't to add a 10 cent trailing stop. I have posted my code below.
    Also, I have two license keys. One that allows me to Sim and live trade. The other only lets me sim trade, but allows me to develop strategies using the ninjascript editor. However I haven't been able to move my strategies over so I can live trade with them. Any help would be greatly appreciated.

    s namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    ///<summary>
    /// executes trades when 9 and 100 sma cross. utilizes trailing stops
    ///</summary>
    [Description("executes trades when 9 and 100 sma cross. utilizes trailing stops")]
    publicclass ninehundred : Strategy
    {
    #region Variables
    // Wizard generated variables
    privateint myInput0 = 1; // Default setting for MyInput0
    // User defined variables (add any user defined variables below)
    #endregion

    ///<summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    ///</summary>
    protectedoverridevoid Initialize()
    {

    CalculateOnBarClose = false;
    }

    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(SMA(9), SMA(100), 1))
    {
    EnterLong(DefaultQuantity, "");
    }

    // Condition set 2
    if (CrossBelow(SMA(9), SMA(100), 1))
    {
    EnterShort(DefaultQuantity, "");
    }
    }

    #region Properties

    #2
    rh017548, I haven't seen any reference in your code to the SetTrailStop function you could use - have you tried adding this on the Stops and Targets section in the wizard?

    Likely you're using a direct license key which does not include system development parts such as the NinjaScript features, if you send your key to my via PM or email to support at ninjatrader dot com I can confirm this further.

    Thanks

    Comment


      #3
      Wow, thanks for that script rh017548, i will try to use it in my practice. Speak in truth i don't use trailing stop much.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      646 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      367 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      107 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      569 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X