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

Trailing Stop

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

    #16
    Tony,

    Depends on who you are connected to. Please see this article: http://www.ninjatrader-support2.com/...ead.php?t=5349
    Josh P.NinjaTrader Customer Service

    Comment


      #17
      TrailStop

      thank you for your email. I´ll work with Mirus (Zen-Fire). Is a trailstop in a strategy an "accepted" or "working" order? And is the trailstop in its new position after being changed an "accepted" or "working" order (and because of this on the exchange)? If so, then the last trailstop becomes a "normal" stoploss in its position of the last change before broken internetconnection?

      Think we got it then.

      Thank you.
      Tony

      Comment


        #18
        Stops will be Accepted. If you lose connectivity it will usually become a regular stop.
        Josh P.NinjaTrader Customer Service

        Comment


          #19
          TrailStop

          Josh,

          thank you! NinjaTrader is a great software. And your support is great!

          Thank you again.
          Tony

          Comment


            #20
            Stoploss

            Hi Josh, Bertrand and everyone

            thank you for your sending the link for "SamplePriceModification". Referring to this sample I tried to push forward stoploss each time the price has risen 10 ticks - it doesn´t work. THANK YOU!

            protected override void Initialize()
            {
            SetStopLoss("", CalculationMode.Ticks, 10, true);
            CalculateOnBarClose = false;
            }

            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {

            if (Position.MarketPosition == MarketPosition.Flat)
            {
            SetStopLoss(CalculationMode.Ticks, 10);
            }

            else if (Position.MarketPosition == MarketPosition.Long)
            {

            if (Close[0] > Position.AvgPrice + 9 * TickSize)
            {
            SetStopLoss(CalculationMode.Ticks, -9);
            }
            }
            else if (Position.MarketPosition == MarketPosition.Short)
            {

            if (Close[0] < Position.AvgPrice - 9 * TickSize)
            {
            SetStopLoss(CalculationMode.Ticks, -9);
            }
            }

            else if (Position.MarketPosition == MarketPosition.Long)
            {

            if (Close[0] > Position.AvgPrice + 19 * TickSize)
            {
            SetStopLoss(CalculationMode.Ticks, -19);
            }
            }
            else if (Position.MarketPosition == MarketPosition.Short)
            {
            if (Close[0] < Position.AvgPrice - 19 * TickSize)
            {
            SetStopLoss(CalculationMode.Ticks, -19);

            }

            Comment


              #21
              Stoploss

              Hi Josh, Bertrand, Jason, Ray....

              now I see my posted reply and it seems strange. To avoid misunderstanding I want to add that my "THANK YOU" is not the answer as my strategy doesn´t work with your sample, I said "Thank you" in advance for your answer and help to the code I´ve sent to you. NinjaTrader has the best support!

              Comment


                #22
                Hello,

                This link may help:


                Also, I think the "-9" should be "9", no negative sign.
                DenNinjaTrader Customer Service

                Comment


                  #23
                  SetStopLoss

                  Hello,

                  I try to change StopLoss referring to the change of price but it doesn´t work and I can´t find the error. Referring to the "SamplePriceModification" my 8 ticks in the stoploss refer to the entryprice or to the new price when stoploss has been changed? Otherwise - as the stoploss is at a higher value (Entry-Price + 16 - 8 = -8) if it refers to the origin entryprice it must be written negative (-8)? (I´ve seen the certain information in the help guide but this doesn´t explain how to change one stoploss for another (or I can´t understand)
                  Thank you.

                  protectedoverridevoid Initialize()
                  {


                  SetStopLoss(
                  "", CalculationMode.Ticks, 10, true);

                  CalculateOnBarClose =
                  true;


                  }
                  protectedoverridevoid OnBarUpdate()
                  {
                  if (Position.MarketPosition == MarketPosition.Flat)
                  {
                  SetStopLoss(CalculationMode.Ticks,
                  10);
                  }

                  elseif (Position.MarketPosition == MarketPosition.Long)
                  {
                  if (Close[0] > Position.AvgPrice + 16 * TickSize)
                  {
                  SetStopLoss(CalculationMode.Ticks,
                  8);
                  }
                  }
                  elseif (Position.MarketPosition == MarketPosition.Short)
                  {
                  if (Close[0] < Position.AvgPrice - 16 * TickSize)
                  {
                  SetStopLoss(CalculationMode.Ticks,
                  8);
                  }
                  }

                  Comment


                    #24
                    tonynt,

                    When you call SetStopLoss(), any tick value you pass in is always based off of your original entry price for the position. If you are trying to move it up a few ticks you would simply decrease the ticks you submit the new stop loss at.

                    Say originally you submit a 10 tick stop loss, after x ticks in profit, you can then resubmit the stop loss at 8 ticks to raise it by 2.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #25
                      SetStopLoss

                      Hello Josh,

                      thank you for your information - this is theoretically 100% clear. But as I wanted to show in my code: how to bring the stoploss ABOVE the entry price? In the code StopLoss starts with 10, then the price rises 16 ticks and I want to set the StopLoss 8 ticks below this price (= 8 ticks above entry price). This doesn´t work.

                      Thank you and best regards.
                      Tony

                      Comment


                        #26
                        Tony, please try this then -

                        Code:
                         
                        if (Close[0] > Position.AvgPrice + 16 * TickSize)
                        SetStopLoss(CalculationMode.Price, Position.AvgPrice + 8 * TickSize);


                        BertrandNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Jonker, Today, 01:19 PM
                        0 responses
                        1 view
                        0 likes
                        Last Post Jonker
                        by Jonker
                         
                        Started by futtrader, Today, 01:16 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post futtrader  
                        Started by Segwin, 05-07-2018, 02:15 PM
                        14 responses
                        1,789 views
                        0 likes
                        Last Post aligator  
                        Started by Jimmyk, 01-26-2018, 05:19 AM
                        6 responses
                        838 views
                        0 likes
                        Last Post emuns
                        by emuns
                         
                        Started by jxs_xrj, 01-12-2020, 09:49 AM
                        6 responses
                        3,294 views
                        1 like
                        Last Post jgualdronc  
                        Working...
                        X