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

Line that trails price bars by a set number of ticks

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

    Line that trails price bars by a set number of ticks

    I would like to create a line that trails the price bars by a set number of ticks (which can also be adjusted later during optimization process).

    Then when price reverses and closes past that line in the opposite direction a trade will be triggered in the new direction.

    I would greatly appreciate any suggestions on the most effective way to do that. I'm just starting to learn how to use the Strategy Builder so I don't know much yet.

    I've been studying the documentation and have watched some videos but would like to find something more thorough. Any suggestions about books, tutorials or a training course?

    Thanks!


    #2
    Welcome to the forums tmillr!

    First and foremost, please be aware of the publicly available Strategy Builder resources below.

    Strategy Builder 301 (publicly available resource) — https://www.youtube.com/watch?v=_KQF2Sv27oE

    Conditions examples —https://ninjatrader.com/support/help...on_builder.htm

    Actions examples — https://ninjatrader.com/support/help...us/actions.htm

    For drawing specifically, please see the section below.



    You wont be able to check properties of the line with your conditions, but you would be able to assign values to a variable the same way you would adjust a horizontal line to be drawn at a certain price. You can create User Defined Inputs for a "distance" from current price and use this distance to offset from the current Close price.

    You could then use the variable for your strategy logic in Conditions and Actions, and the line drawn can be considered a mere visual representation of where this variable lies.

    To reverse positions, you would call EnterShort when long, or EnterLong when short.

    We will have some light tutorials added to the Help Guide in the future, but there are also more in depth training resources on NinjaScript created be members of our EcoSystem. If that is something that interests you, we can have a colleague provide more information.

    We look forward to assisting.

    JimNinjaTrader Customer Service

    Comment


      #3
      Here is screenshot of how I would like to trail the price bars. Could you explain how to create a variable that will track the value, 20 ticks behind each bar that has a higher low.
      Then when price closes below that line it could be an entry signal short.

      Comment


        #4
        Hello tmillr,

        It looks like there is an issue attaching your screenshot.

        Let's think this part through: "each bar that has a higher low."

        This could be done by comparing current Low (BarsAgo 0) to the previous Low (BarsAgo 1) to see if the current Low is greater.

        If this condition is true assign your variable to be the current Close price minus 20 ticks.

        I have attached screenshots showing how you can create a variable and how you can assign it the current Close price - 20 ticks. "-20" can also be your User Defined Input parameter instead of a hardcoded -20.
        Attached Files
        JimNinjaTrader Customer Service

        Comment


          #5
          Thank you for this information. I will work on it.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by nandhumca, Today, 03:41 PM
          0 responses
          3 views
          0 likes
          Last Post nandhumca  
          Started by The_Sec, Today, 03:37 PM
          0 responses
          3 views
          0 likes
          Last Post The_Sec
          by The_Sec
           
          Started by GwFutures1988, Today, 02:48 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by ScottWalsh, 04-16-2024, 04:29 PM
          6 responses
          33 views
          0 likes
          Last Post ScottWalsh  
          Started by frankthearm, Today, 09:08 AM
          10 responses
          36 views
          0 likes
          Last Post frankthearm  
          Working...
          X