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 algospoke, Yesterday, 06:40 PM
          2 responses
          22 views
          0 likes
          Last Post algospoke  
          Started by ghoul, Today, 06:02 PM
          3 responses
          14 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          45 views
          0 likes
          Last Post jeronymite  
          Started by Barry Milan, Yesterday, 10:35 PM
          7 responses
          21 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by AttiM, 02-14-2024, 05:20 PM
          10 responses
          181 views
          0 likes
          Last Post jeronymite  
          Working...
          X