Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

setting stop losses X onBarUpdate()

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

    setting stop losses X onBarUpdate()

    My SetStopLoss("", CalculationMode.Percent, stopLevelMovel, false);
    is inside OnBarUpdate() since stopLevelMovel (the variable used to calculate the Percent is defined realtime)
    Using TraceOrder = true, I checked that the stop has been ordered each minute. (what I intend to change)
    But, my question would be:
    1-why the stop order does not change on Interactive brokers (I am trading for real)?
    2- Can I setup stop order along with enterShort() and enterLong()only?

    #2
    Hello,

    Thank you for the question.

    I would like to check, is the order being changed in NInjaTrader?

    If not this would indicate a logic issue with how the order is being changed. Can you please confirm if this is happening in both NinjaTrader and IB or only in IB.

    For your second question, are you asking if you can associate the Stop with only EnterLong and EnterShort specifically?

    If so, yes you would need to use a signal name with the Entry orders and then specify that signal name in the Stop order to associate the two.

    I look forward to being of further assistance.

    Comment


      #3
      nothing is happening on IB, and I see the new setstoporder on output window.
      it means it is happening on NT, isnt it? should I check another way?

      regarding set stop and enter order. What you mean by specify and order in the stop?
      below is how I intend to do it.

      if (Position.MarketPosition != MarketPosition.Short)
      {
      EnterShort(0,positionTaken, ("InRangeSYV"));

      SetStopLoss("", CalculationMode.Percent, stopLevelMovel*2.7, false);
      }

      Comment


        #4
        Hello,

        You would need to check in the orders tab on the control center, if the order is submitted you should be able to track its progress here and view if it was modified.

        For the order logic you have, if you take a look in the help guide on these order methods we can see the way to use SignalNames: http://www.ninjatrader.com/support/h...sub=EnterShort

        It looks like you are using this overload pattern:
        Code:
        EnterShort(int barsInProgressIndex, int quantity, string signalName)
        So your string ("InRangeSYV"), I am unsure on the reason you are using the ( ), you can simply use "InRangeSYV". This would be the signal name for this specific order, we need to use this later with the SetStopLoss to associate the two.

        The syntax for SetStopLoss would look like:

        Code:
        SetStopLoss("InRangeSYV", CalculationMode.Percent, stopLevelMovel*2.7, false);
        I look forward to being of further assistance.

        Comment


          #5
          Sorry, but I can not find the orders tab on control center.
          Can you give me the whole path toit?

          another question.
          the identification of stop loss on onexecution() is:
          if (execution.Name == "Stop loss" && execution.Instrument.MasterInstrument.Name == "XXXX")???

          Comment


            #6
            Another question would be:
            Can you explain me this:
            SetStopLoss(string fromEntrySignal, CalculationMode mode, double value, bool simulated)
            I ve been using bool simulated false but I can not undestand it, even reading documentation.

            Comment


              #7
              Hello,

              The Orders tab will be in the control center, it is generally the first tab you start in. You can see the tab buttons near the top of the control center.

              For your second question:

              the identification of stop loss on onexecution() is:
              if (execution.Name == "Stop loss" && execution.Instrument.MasterInstrument.Name == "XXXX")???


              Are you asking if this would be correct syntax or what would the question be with this statement?

              If you are asking how to locate a order by its name that would be not be correct, this would be the correct syntax to locate a StopLoss by name from OnExecution:

              Code:
              protected override void OnExecution(IExecution execution)
              {
              	if(execution.Order != null && execution.Order.Name == "Stop loss")
              	{
              		Print(execution.Order.Name);
              	}
              }
              The second portion of your original statement would not be needed as this would only be coming from the instrument the strategy is currently running on.

              I look forward to being of further assistance.

              Comment


                #8
                I got it!
                what about the FALSE on this method? what does it mean?
                SetStopLoss("", CalculationMode.Percent, stopLevelMovel*2.7, false);

                Comment


                  #9
                  Hello dafonseca,

                  Thanks for your reply.

                  Your question about: SetStopLoss(string fromEntrySignal, CalculationMode mode, double value, bool simulated) is directed at the bool for simulated. From the helpguide, if true, will simulate the stop order and submit as market once triggered.

                  Further helpguide definition: Stop loss orders are real working orders (unless simulated is specified in which case the stop order is locally simulated and submitted as market once triggered) submitted immediately to the market upon receiving an execution from an entry order.

                  Here is the full reference: http://www.ninjatrader.com/support/h...etstoploss.htm

                  Comment


                    #10
                    Sorry but I am not understanding what does it mean?
                    simulated - If true, will simulate the stop order and submit as market once triggered

                    What should I use (true or false) when trading for real?

                    Comment


                      #11
                      Hello dafonseca,

                      Thanks for your reply.

                      To clarify:

                      When set to false, the stoploss is sent to the exchange when the entry order is accepted.

                      When set to false, the stoploss is maintained in your pc when the entry order is accepted at the exchange. When the stop condition is reached your pc will then issue a market order to the exchange to exit the position.

                      There are risks and benefits of simulated stops, please see: http://www.ninjatrader.com/support/h...top_orders.htm

                      We cannot provide trading advise regarding which to use.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      558 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      324 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      101 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      545 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      547 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X