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 jclose, Today, 09:37 PM
          0 responses
          4 views
          0 likes
          Last Post jclose
          by jclose
           
          Started by WeyldFalcon, 08-07-2020, 06:13 AM
          10 responses
          1,413 views
          0 likes
          Last Post Traderontheroad  
          Started by firefoxforum12, Today, 08:53 PM
          0 responses
          10 views
          0 likes
          Last Post firefoxforum12  
          Started by stafe, Today, 08:34 PM
          0 responses
          10 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by sastrades, 01-31-2024, 10:19 PM
          11 responses
          169 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X