Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Identifing color of the previous bar on Tick by Tick

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

    Identifing color of the previous bar on Tick by Tick

    Hello,

    I am developing a strategy evaluating on TickbyTick. I need it to identify the color of the previous bar. However, the code does not work. Here if the condition:

    if (CrossBelow(Close, low1, 2) && ( Close[2] > Open[2]) )
    {
    Long()
    }

    #2
    Hello Jorge.andres.o,

    Thanks for your post.

    If you want to see if the previous bar was an up or down bar, you will want to compare the Open and Close from 1 bar ago. We would do this to check for an up bar as opposed to checking the bar color, which the user may change freely.

    I.E.

    if (Close[1] > Open[1])
    Print("Up Bar");

    if (Close[1] < Open[1])
    Print("Down Bar");

    Working with Price Series - https://ninjatrader.com/support/help...ice_series.htm

    Making sure you have enough bars in the data series you are referencing - https://ninjatrader.com/support/help...nough_bars.htm

    We look forward to assisting.

    Comment


      #3
      Jim,

      thank you for the answer. Does it work the same way for onbarclose and tickbytick?

      Comment


        #4
        Hello Jorge.andres.o,

        Yes, BarsAgo references would work the same way where BarsAgo 1 references the pervious bar.

        The main difference with Calculate.OnBarClose vs. OnEachTick/OnPriceChange we should note is that OnBarClose updates when the bar has just closed, and OnEachTick/OnPriceChange continuously update as the developing bar updates instead.

        We look forward to assisting.

        Comment


          #5
          Thank you Jim

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          55 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          132 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          73 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          49 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X