Announcement

Collapse
No announcement yet.

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:

    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    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]

        Comment


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

          World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


          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 Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            578 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 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
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X