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

Finding High from Bars Since Entry

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

    Finding High from Bars Since Entry

    Alright, in an attempt to create a system that has the following:
    x% Firm Stop
    x% Trail Stop
    x% Profit target to dump half the position

    I have created a system of firm stops that move themselves up as the position moves in the right direction:

    Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


    So, as the position moves across variables (labeled CorrectionX in the picture) the stop updates. The price of the updated stop is calculated by multiplying the high of the period by (1-x%)

    So, in order to replicate a trailing stop, I need to find the high of the period. So instead of High[0] above, I need the high of bars since entry.

    Can anyone tell/give me an example of how to do this?

    Thnanks,
    Loren

    #2
    Please use MAX() along with BarsSinceEntry() on High.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Is there any way yo can post an example of this?

      I cannot seem to figure it out for the life of me.

      MAX(BarsSinceEntry) does not work.

      I also cannot seem to get BarsSinceEntry to define as a variable. If that would work I could do High[BarsElapsed] but that also will not work.

      Comment


        #4
        Hi, have you tried something like -
        Code:
        [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] trailStop = MAX(High, BarsSinceEntry())[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]];[/SIZE][/SIZE]
        [SIZE=2][SIZE=2][/SIZE][/SIZE]

        BertrandNinjaTrader Customer Service

        Comment


          #5
          When adding that as a variable the following comes up:

          Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


          I cant find anything about that error message in the tutorial.

          Comment


            #6
            You cannot place that line of code in that area. You need to place it within the OnBarUpdate() method.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ageeholdings, Today, 07:43 AM
            0 responses
            6 views
            0 likes
            Last Post ageeholdings  
            Started by pibrew, Today, 06:37 AM
            0 responses
            4 views
            0 likes
            Last Post pibrew
            by pibrew
             
            Started by rbeckmann05, Yesterday, 06:48 PM
            1 response
            14 views
            0 likes
            Last Post bltdavid  
            Started by llanqui, Today, 03:53 AM
            0 responses
            6 views
            0 likes
            Last Post llanqui
            by llanqui
             
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            12 views
            0 likes
            Last Post burtoninlondon  
            Working...
            X