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

Retrieving a previous bar's color

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

    Retrieving a previous bar's color

    I have successfully built several indicators that color bars specific colors when certain conditions are met. I am now trying to develop strategies to act upon the indicator colors. I know I could program the strategy to use the same logic as the indicator to identify the bars, but it would be much easier if I could just have a strategy that could look back for specific bar colors and then act. Does anyone know how to do this? I am currently using the following language:

    Indicator language, which is working:

    if (conditions met)
    {
    BarBrush = Brushes.Red // colors Bar[0] red when it closes
    }


    Strategy language, NOT working:

    if (BarBrushes[1] == Brushes.Red)
    {
    //perform action
    }

    I've tried referencing bar[0] as well as bar[1] in the strategy language but neither seem to work.​

    #2
    Hello GoCubsGo,

    Thanks for your post.

    There are no NinjaScript methods or properties available to check the bar color within a condition.

    This is achieved by adding the same logic the indicator uses to change the bar color into the strategy logic as you noted.

    Or, you could consider programming the indicator to generate a signal and check for that signal within a condition in the strategy.

    Here is a reference sample demonstrating exposing indicator values that are not plots: https://ninjatrader.com/support/help...alues_that.htm
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rhyminkevin, Today, 04:58 PM
    0 responses
    14 views
    0 likes
    Last Post rhyminkevin  
    Started by lightsun47, Today, 03:51 PM
    0 responses
    6 views
    0 likes
    Last Post lightsun47  
    Started by 00nevest, Today, 02:27 PM
    1 response
    14 views
    0 likes
    Last Post 00nevest  
    Started by futtrader, 04-21-2024, 01:50 AM
    4 responses
    48 views
    0 likes
    Last Post futtrader  
    Started by Option Whisperer, Today, 09:55 AM
    1 response
    15 views
    0 likes
    Last Post bltdavid  
    Working...
    X