Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Assigning SMA to VolumeUpDown

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

    Assigning SMA to VolumeUpDown

    How do I set an SMA to the up volume side of VolumeUpDown and a separate SMA to the down volume side in a strategy script?

    I can do it as an indicator and use it all the time.

    I'd like to be able to use the SMA crosses as conditions...

    Thanks for all your help

    #2
    Hello Darth_Trader,

    I am currently looking into your question and will reply again shortly.

    Thank you for your patience.
    Michael M.NinjaTrader Quality Assurance

    Comment


      #3
      Hello Darth_Trader,

      You can accomplish this by applying an SMA to each of the data series in the VolumeUpDown indicator and then creating a condition for the CrossAbove/Below in the OnBarUpdate() section of your code. For example:

      Code:
      #region Variables
      IDataSeries upSMA, downSMA;
      #endregion
      protected override void OnBarUpdate(){
          upSMA = SMA(VolumeUpDown().Values[0], 14);
          downSMA = SMA(VolumeUpDown().Values[1], 14);
          if(CrossAbove(upSMA, downSMA, 1))
          {
              //Do Something
          }
      }
      NOTE: Because VolumeUpDown has gaps in its' data series, due to the fact that a volume bar cant be both up and down at the same time, the SMA calculations will not always have the full period worth of data calculated in to their value.

      If we may be of further assistance, please let us know.
      Michael M.NinjaTrader Quality Assurance

      Comment


        #4
        Thank You!

        Thanks MichaelM!

        Actually, I'm aware of the gaps, and it actually seems to make the SMA crossover more reactive. I'm using this as a helpful scalp indicator now, but was wondering how I could code it.

        Thanks for all your help!

        - DT

        Comment


          #5
          Hello Darth_Trader,

          I'm glad to hear you were able to get everything working.

          Please let us know if we may be of further assistance anytime.
          Michael M.NinjaTrader Quality Assurance

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          596 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          343 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          556 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          554 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X