Announcement

Collapse
No announcement yet.

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
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    93 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    138 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    123 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    73 views
    0 likes
    Last Post PaulMohn  
    Working...
    X