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

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 geotrades1, Today, 08:33 AM
          0 responses
          0 views
          0 likes
          Last Post geotrades1  
          Started by elirion, Yesterday, 10:03 PM
          7 responses
          18 views
          0 likes
          Last Post elirion
          by elirion
           
          Started by tkaboris, Today, 08:32 AM
          0 responses
          1 view
          0 likes
          Last Post tkaboris  
          Started by elirion, Yesterday, 09:48 PM
          4 responses
          24 views
          0 likes
          Last Post elirion
          by elirion
           
          Started by f.saeidi, Today, 07:07 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X