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

volume

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

    volume

    I know how to code a new horizontal line to volume to help me keep an eye on whether its large enough or not for trades depending on if vol is above or not.

    I'd rather only have the volume bar recolor green if it's over an input choice for size, otherwise it stays the default color.

    I tried using strategy builder then copying the new parts into my vol indicator but that did not work so i deleted the try. (Why is strategy builder and not indicator builder the only way to set up coded conditions?)

    I know if i add an input variable, i need to add it to properties, but how do i code the if statement(s) and do i need to add a plotcolor for upvolume bars?
    Last edited by simpletrades; 07-05-2011, 10:32 AM.

    #2
    simpletrades, you'll have to define the if statements you want to use yourself, but once you get those figured out it is pretty easy to change the bar color:
    Code:
    BarColor = Color.Green;
    In addition to changing the bar color, you can also change the background color:
    Code:
    BackColor = Color.Blue;
    AustinNinjaTrader Customer Service

    Comment


      #3
      i know how to do barcolor and background color.
      I have problems defining the indicator.
      forgetting variables to make the level changeable (which i know how to do once i get a set level to work), i never get the if statements naming the indicator correct.

      Volme is my version with a line
      and Volme2 is with the barcoloring that wont compile.

      I tried
      If (Volume[
      0]>=140)
      and also
      If (Volume2[0]>=140)

      neither worked.
      Attached Files

      Comment


        #4
        simpletrades, the if (volume[0]>140) line should work.

        When you start a new indicator, it asks you if there are any variables you want created. Once you create one of these variables, you can reference it in your script.

        In the attached indicator, I named the variable VolumeLimit, and volume is compared to it and then colors the bar if the conditions are met.

        Please take a look at the code and let me know if you have any questions about it.
        Attached Files
        AustinNinjaTrader Customer Service

        Comment


          #5
          sort of.
          i wanted the volume bars to recolor so i changed overlay to false.
          now i only have to add in the original vol code to get a histogram.
          thanks for the help.

          I did notice one thing--I always thought the way a line item reads in variables
          volumeLimit for example, is how it was supposed to read in the calculation parts
          if
          (Volume[0] > VolumeLimit)

          but in variables volumeLimit is not captalized but later it was.
          I thought the only time it gets capitalized regardless of how variables reads was in properties ?
          public
          int VolumeLimit

          Comment


            #6
            Still not working right.
            here's what i have--but it draws an orange volume line instead of blue or green bars.
            I have the code reading BackColor because when it read BarColor it was only coloring the candles blue/green. See the picture.
            protectedoverridevoid Initialize()
            {
            Add(
            new Plot(new Pen(Color.DodgerBlue, 2), PlotStyle.Bar, "Volume"));
            Add(
            new Line(Color.DarkGray, 0, "Zero line"));
            Add(
            new Line(Color.Green, 140, "Threshhold"));
            Overlay =
            false;
            }
            ///<summary>
            /// Called on each bar update event (incoming tick)
            ///</summary>
            protectedoverridevoid OnBarUpdate()
            {
            {
            Value.Set(Volume[
            0]);
            }

            if (Volume[0] > VolumeLimit)
            BackColor = Color.Green;
            else BackColor=Color.DodgerBlue;
            }
            Attached Files

            Comment


              #7
              Hello,

              If you recently changed the Add() command you need to completely remove the indicator from the chart and re-add it since the settings only load on indicator apply to the chart. Therefor you will want to remove and re-add the indicator instead of reload NinjaScript.

              Let me know if I can be of further assistance.

              Comment


                #8
                I still dont get it.
                i changed the code to start with red volume then use blue/green for barcolor per the threshhold.
                What i get are red vol bars but blue/green candles.
                see attached
                Attached Files

                Comment


                  #9
                  simpletrades,

                  The code you're using is for assigning color to bar. These are always going to be the OHLC bars. To change the color of the indicator plot itself, there is a different technique, using the PlotColors property. This technique is shown here:
                  Last edited by NinjaTrader_RyanM1; 07-05-2011, 01:54 PM.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    i ended up combining what you had me doing as the condition with the ninja 7 indicator VolumeUpDown which has histogram colorchanging depending on the candle open/close which i switched out.
                    thanks.

                    Comment


                      #11
                      Simpletrades,
                      Would you be kind enough to post your final indicator? Thanks in advance.

                      Comment


                        #12
                        here
                        set volume limit and volume threshhold to what you want. both numbers should be the same.
                        Attached Files

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by usazencort, Today, 01:16 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post usazencort  
                        Started by kaywai, 09-01-2023, 08:44 PM
                        5 responses
                        603 views
                        0 likes
                        Last Post NinjaTrader_Jason  
                        Started by xiinteractive, 04-09-2024, 08:08 AM
                        6 responses
                        22 views
                        0 likes
                        Last Post xiinteractive  
                        Started by Pattontje, Yesterday, 02:10 PM
                        2 responses
                        21 views
                        0 likes
                        Last Post Pattontje  
                        Started by flybuzz, 04-21-2024, 04:07 PM
                        17 responses
                        230 views
                        0 likes
                        Last Post TradingLoss  
                        Working...
                        X