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 NullPointStrategies, Today, 05:17 AM
    0 responses
    23 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    120 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    63 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    45 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X