Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

market order - strategy handling

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

    market order - strategy handling

    Hi,
    here my thoughts:
    I want enter the market manually by limit order without any stopp order to protect the position.. - no problem so far.
    After I have an position in the market I want to activate a stratgie which adjusted added a stopp to protect the position. The adjusting stopp follows the Parabolic indicator.

    But it does'nt work I read the tutorial and example, nothing helps.
    Here are so code:

    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Long Exit nach Parabolic
    /// </summary>
    [Description("Long Exit nach Parabolic")]
    public class ParabolicStopLong : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int periode = 1; // Default setting for Periode
    // 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>
    protected override void Initialize()
    {
    Add(ParabolicSAR(Median, 0.02, 0.2, 0.02));

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (Median[0] < ParabolicSAR(Median, 0.02, 0.2, 0.02)[0])
    {
    ExitLong("Exit", "");
    }
    }

    #region Properties
    [Description("")]
    [GridCategory("Parameters")]
    public int Periode
    {
    get { return periode; }
    set { periode = Math.Max(1, value); }
    }
    #endregion
    }
    }

    #2
    razorbuzz67, having a NinjaScript strategy manage a manually taken trade is unfortunately not supported.

    The trade entry would have to come from the NinjaScript strategy, too to be able to manage the position by a custom stop like your SAR.

    Comment


      #3
      ok next step.
      I do a trick.
      I enter the market short when median price is under sma: order filled, when I checked the stratgie. everthing fine. but the parabolic stopp dosen't work

      here the code


      #region Using declarations
      using System;
      using System.ComponentModel;
      using System.Diagnostics;
      using System.Drawing;
      using System.Drawing.Drawing2D;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Data;
      using NinjaTrader.Indicator;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Strategy;
      #endregion

      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
      /// <summary>
      /// Enter the description of your strategy here
      /// </summary>
      [Description("Enter the description of your strategy here")]
      public class ParabolicStopShort : Strategy
      {
      #region Variables
      // Wizard generated variables
      private int periode = 1; // Default setting for Periode
      // 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>
      protected override void Initialize()
      {

      CalculateOnBarClose = false;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (Median[0] < SMA(20)[0])
      {
      EnterShort(DefaultQuantity, "");
      }

      // Condition set 2
      if (Median[0] > ParabolicSAR(0.02, 0.2, 0.02)[0])
      {
      ExitShort("", "Exit short");
      }
      }

      #region Properties
      [Description("")]
      [GridCategory("Parameters")]
      public int Periode
      {
      get { return periode; }
      set { periode = Math.Max(1, value); }
      }
      #endregion
      }
      }

      Comment


        #4
        You are tieing the ExitShort to the wrong Entry signal name, hence it's not picked up.

        To debug orders in your strategy, TraceOrders are very helpful -

        Comment


          #5
          ok - works now - perfect.

          additional question:
          wehn i created the same with indicator TSSuperTrend,( from sharing section )
          I get an error on line 51. but it looks ok for me. Known issue?

          Comment


            #6
            I would unfortunately not know the reason why you see this, if you double click on the error it spots which call produces an issue, would you mind posting it?

            Comment


              #7
              ok my fault. works.
              another question:
              How can I use the following:
              If the strategy 3times loss ( so the first 3 trades are loosers ) stop the strategy.
              or another thinking:
              if the strategy down to daily losses .e.g. 500 $, than stop the strategy.

              thanks in advance for help.

              Comment


                #8
                Hello,

                Please use the following guide for this:



                Let me know if I can be of further assistance.
                BrettNinjaTrader Product Management

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                662 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                376 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                110 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                575 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                580 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X