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

BarColor in multi-timeframe

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

    BarColor in multi-timeframe

    Support/Josh

    In a multi-timeframe strategy,the way one references the other timeframe bars is like Lows[0][0] or Highs[0][0]. But is there anyway to color the bars of lowertimeframe based on highertimeframe conditions.

    Like if I do this in ninjascript it is not coloring bars in lower timeframe

    ===============
    if (BarsInProgress == 1 ) // highertimeframe
    {
    if (condition1_in_higher_timeframe)
    {
    //color Bars in lower timeframe
    BarColor = Color.Green;
    }
    }

    =============

    Should one do as below to reference lower timeframe barcolor while processing higher timeframe conditions.
    BarColors = Color.Green;

    or
    BarColors[0] = Color.Green;

    --
    Shooter

    #2
    Shooter, which timeframe do base this and which timeframe do you add? BarColor would also work in your MultiTimeStrategy.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand, thanks for the reply.

      But how do I refer to lower timeframe BarColor, when one is processing higher timeframe conditions? For example strategy is loaded on 1 min chart and the higher timeframe 5 min is added. While processing 5 mins bars, "BarColor" is referring to 5 min bar's color correct? How do I refer to 1 min Barcolor,..is it by "BarColor[o]", so that one can color 1 min chart based on 5 min timeframe?


      --
      Shooter

      Comment


        #4
        Shooter,

        Unfortunately programmatically accessing the colors is not supported. You can only set them.

        If you want to see if it is a red/green bar just run the Opens[1][0] > Closes[1][0] check. If you are checking for a bar color set by a strategy/indicator, you should expose a property that states that such a color was set instead of actually checking bar color.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Josh,

          Thanks for your reply. Just to clarify, I am not trying to access BarColor of lower timeframe, I am trying to set them. Basically trying to set the BarCOlor of timeframe bars based on condition set of higher timeframe bars.

          ===============
          if (BarsInProgress == 1 ) // highertimeframe
          {
          if (condition1_in_higher_timeframe)
          {
          //color Bars in lower timeframe
          BarColor = Color.Green;
          }
          }

          =============
          The above code ,when treid to not coloring 1 min Bars, the chart on which it is loaded.

          --
          Shooter

          Originally posted by NinjaTrader_Josh View Post
          Shooter,

          Unfortunately programmatically accessing the colors is not supported. You can only set them.

          If you want to see if it is a red/green bar just run the Opens[1][0] > Closes[1][0] check. If you are checking for a bar color set by a strategy/indicator, you should expose a property that states that such a color was set instead of actually checking bar color.

          Comment


            #6
            shooter, just tried this simple snippet on the ES and it plotted correctly -

            Code:
             
            if (Closes[1][0] > SMA(BarsArray[1], 20)[0])
            {
            BarColor = Color.Blue;
            }
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thanks Bertrand. But if one processes higher timeframe bars and adds the line
              if (BarsInProgress == 1 ), before the code, its not processing the lower timeframe barcolor


              Code:
               
              if (BarsInProgress == 1 )
              {
                 if ( Close[1][0] > SMA(20)[0] ) //processing bars in 5 min chart
                  {
                    BarColor = Color.Blue;  //should color bars in 1 min chart if it works
                  }
              }
              or am I missing something obvious here.

              --
              Shooter

              Originally posted by NinjaTrader_Bertrand View Post
              shooter, just tried this simple snippet on the ES and it plotted correctly -

              Code:
               
              if (Closes[1][0] > SMA(BarsArray[1], 20)[0])
              {
              BarColor = Color.Blue;
              }

              Comment


                #8
                I'm not sure I follow, when you intend to color the primary bars object you should check for BarsInProgress == 0 - the higher timeframe condition is already expressed in working with BarsArray[1]. Just rechecked and works on my end.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Thanks Bertrand and Josh. Appreciate it.

                  I was processing BarsinProgress=1, for higher timeframe and was somehow trying to make the lower timeframe bars colored while processing highertimeframe bars. Looks like the only way to set the lower timeframe barcolor is to use,BarsinProgress==0 and then set BarColor accordingly. Will try that.

                  --
                  Shooter

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by royhagerman, Today, 04:30 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post royhagerman  
                  Started by haas88, 03-21-2024, 02:22 AM
                  18 responses
                  208 views
                  0 likes
                  Last Post haas88
                  by haas88
                   
                  Started by Board game geek, Today, 02:20 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post Board game geek  
                  Started by knighty6508, Today, 01:20 AM
                  2 responses
                  16 views
                  0 likes
                  Last Post knighty6508  
                  Started by franatas, Today, 01:53 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post franatas  
                  Working...
                  X