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

How to manually update stoplimit?

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

    How to manually update stoplimit?

    Hi,

    I want to be able to control where the stop order moves instead of having to use the settrailstop.

    How can i basically say move my setstoploss to the lowest of the last five bars - 3 for a long and have it moved down to the hightest of the last five bars +3. I'm trying to figure this out but the setstoploss seems to have currency, pips, ticks, percentage as option but i want to set it manually to what i described above.

    Please let me know if there are any examples or a line of code i can refer to that i can use in my strategy.

    Thank you.

    #2
    Hello priceisking,

    I do have an example of trailing (and chasing) you may find helpful linked below.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Any chance you can make a quick video explaining what the script "ProfitChaseStopTrailSetMethodsExample_NT8.zip " does?

      I'm a intermediate programmer and need some help explaining what it's trying to do. I know how to code but just need some explaining on the logic and how ninjatrader behaves .

      Thank you so much in advance.

      Comment


        #4
        Hello priceisking,

        When flat it enters a long position and places an order as a stop loss and an order as a profit target.

        If the price goes down the profit target chases and will be no more than the preset distance (in ticks).

        If the price goes up the stop loss trails and will be no more than the preset distance.

        This continues until one of the orders fill.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi,

          Thank you for the brief summary.

          Can you explain this part to me in the code:


          if (BarsInProgress == 0)
          {
          .
          .
          .
          }


          if (BarsInProgress == 1 && Position.MarketPosition == MarketPosition.Long)
          {
          }


          I'm assuming BarsInProgress == 0 means a 1 minute chart. But will that "if statement" not execute if the chart is running on 5 minute ?

          Also, the second if statement only has for long, should i add a similar if statement for shorts for my logic ?

          Comment


            #6
            Hello priceisking,

            When multiple series are added to a script, the BarsInProgress represents the index of that series.

            0 is the primary series of the chart (or what is selected in the Data Series in the strategy parameters).

            1 would be the first added secondary series.

            My example adds a 1 tick series. When BarsInProgress 0 is processing the primary bar is closing and I place my entry. When BarsInProgress is 1, then a tick was received and I trigger the trailing / chase logic on every received tick.

            Below is a link to a forum post on intra-bar granularity.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              I do have an example of trailing (and chasing) you may find helpful linked below.
              https://ninjatrader.com/support/foru...345#post521345

              Hello @Chelsea,
              I do not really understand how this ProfitChaseStopTrailSetMethodsExample_NT8 works, ( … “unmanaged” vs the “set” methods). However, since I could not see any specific entry condition on your ProfitChaseStopTrailSetMethodsExample_NT8, I tried to insert a long entry condition based on a simple 3linebreak pattern.
              The new strategy “ProfitChaseModify01”compiles, but it does not trigger any trade. Can you please explain how to get trades triggered with the added condition?
              Thank you.
              Attached Files

              Comment


                #8
                Hello guidoisot,

                The EnterLong() call in ProfitChaseStopTrailSetMethodsExample is on line105.

                The action block of the condition set it is in requires that the position be flat and the time not be after the exit on close.

                In other words, a new order is placed anytime the position is flat when a primary bar closes.

                (Try running this script and allowing one of the limit or stop orders to close the position. Notice a new position is entered immediately on a new bar)


                With your entry condition, are you using prints to ensure the condition is evaluating as true on the bar time you are expecting?

                Below is a public link to a forum post that demonstrates using prints to understand behavior.


                Print the bar time and the values of all variables used in the condition set.
                Please include the output from your prints and I will be happy to assist you in analyzing the output.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by GLFX005, Today, 03:23 AM
                0 responses
                1 view
                0 likes
                Last Post GLFX005
                by GLFX005
                 
                Started by XXtrader, Yesterday, 11:30 PM
                2 responses
                11 views
                0 likes
                Last Post XXtrader  
                Started by Waxavi, Today, 02:10 AM
                0 responses
                6 views
                0 likes
                Last Post Waxavi
                by Waxavi
                 
                Started by TradeForge, Today, 02:09 AM
                0 responses
                14 views
                0 likes
                Last Post TradeForge  
                Started by Waxavi, Today, 02:00 AM
                0 responses
                3 views
                0 likes
                Last Post Waxavi
                by Waxavi
                 
                Working...
                X