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

How to avoid changing the color of the candle until the bar is closed?

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

    How to avoid changing the color of the candle until the bar is closed?

    I have an indicator that depending on some parameters I paint the candle one way or antoher, what I want is to paint this candle when the bar closes. I'm using `onBarClose()` and the configurator is `Calculate = Calculate.OnBarClose;`. what I want is when a new candle is generated paint it using for instance Brushes.Pink, and when it closes do the logic I already have to paint it in the correct color.
    So if I'm on a char of 1 min, in the 0:59:00 what is going to happen even if the price is going up/down the candle color would be Brushes.Pink, and once it is 0:00:00 (a new bar is added to the chart) it is not as the real color (previously calculated by algo)

    How can I do it?

    #2
    Hello cmtjoancolmenero,

    Thank you for your post.

    Using Calculate.OnBarClose would mean the logic would only be executed once the bar has closed.

    "what I want is when a new candle is generated paint it using for instance Brushes.Pink, and when it closes do the logic I already have to paint it in the correct color."

    If you want to change the color of the currently forming bar, you could need to use Calculate.OnPriceChange or Calculate.OnEachTick. With either of these Calculate settings, Close[0] would be the currently forming bar. To change the color of the previously closed bar, you can access it by using Close[1]. [1] will be the just closed bar in this mode.



    Please let us know if you have any further questions.
    Gaby V.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NeoTraderBot, Yesterday, 10:55 PM
    0 responses
    6 views
    0 likes
    Last Post NeoTraderBot  
    Started by OliverWaters, Yesterday, 10:35 PM
    0 responses
    6 views
    0 likes
    Last Post OliverWaters  
    Started by Graci117, 07-06-2024, 09:32 AM
    6 responses
    37 views
    0 likes
    Last Post Graci117  
    Started by AdamDJ8, 07-01-2024, 06:50 PM
    2 responses
    120 views
    0 likes
    Last Post AdamDJ8
    by AdamDJ8
     
    Started by AdamDJ8, 07-01-2024, 05:55 PM
    3 responses
    32 views
    0 likes
    Last Post AdamDJ8
    by AdamDJ8
     
    Working...
    X