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 can I retrieve the bar color within a strategy

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

    How can I retrieve the bar color within a strategy

    Hi,

    I have a simple indicator which changes the bar color on certain conditions. The indicator is my own and it works absolutley fine.

    However, I want to be able to find out what the current bar color is from within a strategy and just can't find the correct way to do this.

    From within my strategy I want to do something like...

    MyIndicator.BarColor == Color.Blue

    I'm trying to use the same structure within the indicator used for passing back/forth information to the indicator setup dialog and the strategy wizard "plot" parameter. I can see how to do this for a plot but as the bar color is just a property rather than a data series I can't see how to do it, or find any examples!!

    The only other thing I can think of is to create a public variable within the indicator and access this directly, not sure this will work but that's my next step. Alternatively I could merge the indicator within the strategy which I'd rather not do.

    Hope this makes sense to anyone! If you can point me in the direction of an indicator which does this sort of thing I can use as a model that woudl be great!!

    Thanks

    Oz

    #2
    Hi oz-dog,

    Please see the below sample that details the process of exposes a series or object to a strategy:
    TimNinjaTrader Customer Service

    Comment


      #3
      Hi Tim,

      Fantastic, just what I was looking for!

      Thanks for the super fast response, really appreciated.

      Oz.

      Comment


        #4
        Hi Tim,

        Hmmm... not sure why but I can't get this to work properly.

        I've modelled the example and both the indicator and the strategy compile but the values (bool in this case) do not appear to be passed back to the strategy.

        I've put Print statements in both the indicator and strategy at the points that the bool values are set and the indicator is correctly setting its "bull and bear" variables. However the values returned from the call to this indicator in the strategy are always false.

        I also noticed that in the output window first all of the "strategy" output is printed followed by all of the "indicator" output, not sure if this means anything probably just buffering but thought I'd mention it!

        I've looked over both examples again and can't see any obvious differences, I've even used the same variable names so that I could copy and paste to avoid typos.

        Any ideas?

        Thanks again for your help.

        Oz

        Comment


          #5
          Hi oz-dog,

          Are you getting any errors in the Log tab?
          Can you try importing the samples to see if they work as expected, from the native code, by changing it suit your needs, then transferring it (copying it to) your code?
          Last edited by NinjaTrader_Tim; 11-24-2010, 01:05 PM.
          TimNinjaTrader Customer Service

          Comment


            #6
            Hi Tim,

            Thanks, I always forget to look at the log!

            It has a repeated entry of the type:

            "Error on calling the 'OnBarUpdate' method for indicator 'MyImpulseSystem' on bar 20: Object reference not set to an instance of an object"

            This also appears this morning before I even started looking at the passing back of results so I assume this is highlighting a bug in my indicator? The indicator works fine though - any suggestions on what type of problem this might be to help me narrow the field?

            Thanks

            Oz

            Comment


              #7
              Hi Tim,

              Bug found, all sorted.

              Thanks again for all your help.

              Oz

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by guillembm, Yesterday, 11:25 AM
              3 responses
              16 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by junkone, 04-21-2024, 07:17 AM
              10 responses
              148 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by tsantospinto, 04-12-2024, 07:04 PM
              6 responses
              101 views
              0 likes
              Last Post tsantospinto  
              Started by rocketman7, Today, 02:12 AM
              5 responses
              26 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by ZenCortexReal, Today, 08:54 AM
              0 responses
              1 view
              0 likes
              Last Post ZenCortexReal  
              Working...
              X