Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limit order question

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

    Limit order question

    I have a strategy I would like to add a limt order upon the stoploss being activated at the stop price.

    I was thinking something like:

    if (SetStopTarget("Long"))
    {
    EnterLongLimt (10000, "LL")
    }

    This of course is not correct. Can you point me in the right direction?
    Thank you,

    #2
    Jeff 15,

    You will have to work within the OnOrderUpdate() method to submit an order off of an order event. Please see the reference sample section of the forums for an idea of how to use OnOrderUpdate(): http://www.ninjatrader-support2.com/...ead.php?t=7499
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Im a little closer

      Ok, I read the info you sent me and the help guide on "OnOrderUpdate" I have amended my stategy. I think I should have the new limit order under Onexecution because I only want it entered if it is stopped out. Im not sure how to have the EnterLongLimit recognize the new limit price as the executed stoploss. I have attached a sceen shot.

      Thank you for help.
      Attached Files

      Comment


        #4
        Jeff 15,

        You need to store the stop loss price you used into your own variable. Then you can reference it again in OnExecution.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Guide?

          Can you tell me where I might reference this in the help guide or support forum?

          Thank you,

          Comment


            #6
            Jeff 15,

            There is no reference. It is a simple programming concept. Whatever value you decide to use as your stop loss, also save it into a variable.

            General idea. Untested code.
            Code:
            myStop = Close[0] + 15 * TickSize;
            SetStopLoss(CalculationMode.Price, myStop);
            ....
            EnterLongLimit(myStop);
            Something like that.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Save as variable

              I read as much as I could find on saving variables. I think Im pretty close. Im just having trouble asigning the variable. I have attached screen shot. Any advice would be great.

              Thank you,
              Attached Files

              Comment


                #8
                Jeff 15,

                You cannot use the word TickSize as your variable since this is a reserved word. All you need to do is declare yourself a variable as a double then you can store whatever value you want.

                In Variables section of your code:
                private double myVar = 0;

                In your OnExecution somewhere
                myVar = execution.Order.AvgFillPrice;

                To use this value now you can just call myVar.
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                85 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                47 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                29 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                32 views
                0 likes
                Last Post TheRealMorford  
                Started by Mindset, 02-28-2026, 06:16 AM
                0 responses
                67 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Working...
                X