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 Hwop38, 05-04-2026, 07:02 PM
            0 responses
            173 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Started by CaptainJack, 04-24-2026, 11:07 PM
            0 responses
            328 views
            0 likes
            Last Post CaptainJack  
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            252 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            354 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            181 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Working...
            X