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

Adding Threshold to HMA Indicator

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

    Adding Threshold to HMA Indicator

    Hello,

    I am developing a simple strategy using the HMA Indicator. I watched a video recently where he had a custom HMA and was able to add a threshold of about .3 and it was able to filter out the flat parts of the day and indicate the bigger swings. I have been searching all over and cannot find anything about adding a threshold to an indicator. Does someone have an HMA Indicator with a customizable threshold they can link or at least code the can paste so I can make one?

    Thank you in advance!

    Connor.

    #2
    Hello Connor,

    Thanks for your post and welcome to the NinjaTrader forums!

    Based on the limited description I suspect that the threshold relates to the "slope" of the HMA line.

    While we normally do not provide complete code, I've created an example indicator for you and have attached it and a screenshot example. The indicator allows you to specify the period of the HMA, the size of the filter (threshold) and the number of bars to use for the slope calculation. When the HMA is above the filter the plot will be colored green, when below the opposite side of the filter will be colored red, when in between the filter (+/- 0.3) the plot will be colored gold.

    You will need to apply the indicator to your instruments of choice and observe what combination of HMA period, number of bars to include in the slope calculation and the threshold value works best to meet your needs. To further assist in this direction, I included a bool variable that you can turn on to also print the actual values of the slope to the Ninjascript output window. (this feature is set to false so it will only print when you set it true by checking the Print Slope checkbox). Checking the values calculated is a good way to see why the colors show as they do if you switch instruments, periods, etc.

    Once you have figured out what works, you can then use parts of the code in your strategy to accomplish your goal.

    Here are links to the methods in the example:

    Slope(): https://ninjatrader.com/support/help...-us/?slope.htm
    PlotBrush[][]: https://ninjatrader.com/support/help...lotbrushes.htm
    Attached Files
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      That is exactly what I needed! Thank you so much Paul!

      Comment


        #4
        Is there any reason we can't see the attached code file in this example? hmafilterexample?

        I was hoping to understand this as well.

        Thanks - B

        Comment


          #5
          Originally posted by btwaugh06 View Post
          Is there any reason we can't see the attached code file in this example? hmafilterexample?

          I was hoping to understand this as well.

          Thanks - B
          Hello,
          The code is attached right below the snapshot, here I am attaching again for you.
          HMAFilterExample.zip

          Comment


            #6
            Hi! I've been trying to modify the HMAFilterExample.zip to add the Up and Down colors to the Plot section. I keep getting a compiling error. Can someone tell me how to modify the code? Thanks!

            Comment


              #7
              Originally posted by alnghiem View Post
              Hi! I've been trying to modify the HMAFilterExample.zip to add the Up and Down colors to the Plot section. I keep getting a compiling error. Can someone tell me how to modify the code? Thanks!
              alnghiem

              I've attached zip

              "HMA Filter Coloured Plots NT8"

              Click image for larger version  Name:	HMA Filter Coloured Plots.jpg Views:	0 Size:	42.4 KB ID:	1204819

              I also added "Show HMA" and "Show Indicator Name"

              Hope it helps.
              Last edited by dj22522; 06-11-2022, 05:10 AM.

              Comment


                #8
                Hi dj22522! I don't see a file attached. Can you please send it again? Thanks for your help!

                Comment


                  #9
                  Originally posted by alnghiem View Post
                  Hi dj22522! I don't see a file attached. Can you please send it again? Thanks for your help!
                  I attached it to my last post I don't understand why it's gone.

                  Here it is again.

                  Enjoy.
                  Attached Files

                  Comment


                    #10
                    Thanks dj22522! Appreciate the quick response!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by jclose, Today, 09:37 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post jclose
                    by jclose
                     
                    Started by WeyldFalcon, 08-07-2020, 06:13 AM
                    10 responses
                    1,413 views
                    0 likes
                    Last Post Traderontheroad  
                    Started by firefoxforum12, Today, 08:53 PM
                    0 responses
                    11 views
                    0 likes
                    Last Post firefoxforum12  
                    Started by stafe, Today, 08:34 PM
                    0 responses
                    11 views
                    0 likes
                    Last Post stafe
                    by stafe
                     
                    Started by sastrades, 01-31-2024, 10:19 PM
                    11 responses
                    169 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Working...
                    X