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 CarlTrading, 03-31-2026, 09:41 PM
            1 response
            152 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            89 views
            1 like
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            133 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            127 views
            1 like
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            107 views
            0 likes
            Last Post CarlTrading  
            Working...
            X