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

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.
    JimNinjaTrader Customer Service

    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.
        JimNinjaTrader Customer Service

        Comment


          #5
          Thank you Jim

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by judysamnt7, 03-13-2023, 09:11 AM
          4 responses
          59 views
          0 likes
          Last Post DynamicTest  
          Started by ScottWalsh, Today, 06:52 PM
          4 responses
          36 views
          0 likes
          Last Post ScottWalsh  
          Started by olisav57, Today, 07:39 PM
          0 responses
          7 views
          0 likes
          Last Post olisav57  
          Started by trilliantrader, Today, 03:01 PM
          2 responses
          21 views
          0 likes
          Last Post helpwanted  
          Started by cre8able, Today, 07:24 PM
          0 responses
          10 views
          0 likes
          Last Post cre8able  
          Working...
          X