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

Indicator that measures distance from EMA of current candle

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

    Indicator that measures distance from EMA of current candle

    Hello,
    I have been looking through the huge list of indicators to see if I can find one that measures the distance from EMA to the current candle. For example, it asks for what EMA you want let's say EMA13 for starters, and then it would always tell you how man ticks away from that EMA the closest part of the current candle is.
    Thank you in advance for any assistance you can provide.

    #2
    Hello WeyldFalcon,

    Thanks for your post.

    I am not aware of a specific indicator that does this.

    If you would like to create this yourself we can provide references to Ninjascript that will help.

    I put together a quick example for you and you are welcome to use it as is or modify it to suit your needs. It will show the ticks difference between the current close price and the current price, in ticks. It runs with Calculate.OnPriceChange so it is always referencing the currently forming bar and currently forming EMA.

    A negative value means the EMA is above the bar and a positive value means the EMA is below the bar.
    It will only show the ticks away when connected to real-time or market replay data. It will only show on the current bar.


    Here is a basic guideline of how to import NinjaScript add-ons in NinjaTrader 8:

    Note — To import NinjaScripts you will need the original .zip file.

    To Import:
    1. Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
    2. From the Control Center window select the menu File>utilities>Import Ninjascript...
    3. Select the downloaded .zip file
    4. NinjaTrader will then confirm if the import has been successful.

    Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'

    Once installed, you may add the indicator to a chart by:
    • Right-click your chart > Indicators... > Select the Indicator from the 'Available' list on the left > Add > OK

    EMATicksAwayNT7.zip
    Last edited by NinjaTrader_PaulH; 01-21-2021, 02:39 PM. Reason: Removed NT8 references.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello WeyldFalcon,

      Just to follow-up with another post.

      I made the mistake of providing an NT8 indicator so I apologize for my oversite for the Forum.

      I have removed the indicator in post #2 and replaced it with an NT7 indicator that is the same.

      I also adjusted the download directions for NT7.
      .


      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Hello Paul,
        Thank you for creating a sample and yes I would love to take a look at it and see what I can do to make it work for my needs. I would prefer NT8 as that is what I am using, would you be able to switch it back, please?

        Comment


          #5
          Hello WeyldFalcon,

          Thanks for your reply.

          Here is the NT8 version: EMATicksAway.zip
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Can you please move this over to NT8? Thank you for moving the other one over.
            In case anybody reading this thread is interested here is the code I ended going with.
            TheEMA[0] = myEMA[0]; // plot historical and real time.

            if (State != State.Realtime) // only draw ticks on real time
            return;

            int TicksAway =0;
            if (myEMA[0]>myEMA[1])
            TicksAway = Convert.ToInt32((Low[0] - myEMA[0]) / TickSize);
            else
            TicksAway = Convert.ToInt32((myEMA[0]-High[0]) / TickSize);

            Draw.Text(this, "test", TicksAway.ToString("n0"), 0, Open[0], textColor);

            Comment


              #7
              How would I make sure this Indicator does not go off of the chart?
              When the chart moves up or down far enough the numbers are off of the chart. I tried turning on Auto Scale but that does not seem to work. Did I need to add something to the Indicator to allow Auto Scale to work?

              Comment


                #8
                Hello WeyldFalcon,

                Thanks for your reply.

                In the case of draw objects, you would need to select the method overload that includes the bool IsAutoscale
                Reference; https://ninjatrader.com/support/help...?draw_text.htm

                The last two (either) are what you would need to use to have the Text autoscale added to the chart's autoscaling.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  I keep getting a The name 'True' does not exist in the current context. Can you send me a sample of a Draw.Text that would work with Auto scale?

                  Comment


                    #10
                    Hello WeyldFalcon,

                    Thanks for your reply.

                    If by True you are trying to provide for the Autoscale, it would need to be lower case true.

                    Here is an example:

                    Draw.Text(this, "difflowb" + CurrentBar, true, "BBB", 0, Low[0] - 13 * TickSize, 0, Brushes.Red,new SimpleFont ("Arial",13), TextAlignment.Center, Brushes.Cyan,Brushes.Yellow,100);
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      Click image for larger version

Name:	Capture.jpg
Views:	1151
Size:	12.4 KB
ID:	1140075
                      Well that changed things considerably but now the text has a box around it and it still is not auto scale. Notice how the numbers and the box they are in went off the screen?

                      Comment


                        #12
                        Originally posted by NinjaTrader_PaulH View Post
                        Hello WeyldFalcon,

                        Thanks for your reply.

                        If by True you are trying to provide for the Autoscale, it would need to be lower case true.

                        Here is an example:

                        Draw.Text(this, "difflowb" + CurrentBar, true, "BBB", 0, Low[0] - 13 * TickSize, 0, Brushes.Red,new SimpleFont ("Arial",13), TextAlignment.Center, Brushes.Cyan,Brushes.Yellow,100);
                        Hi Paul,

                        What are "difflowb" and "BBB" ? How and where do you define them ? In the alternative, could you please post an update to EMATicksAway indicator (if the update addresses my questions).

                        Omololu

                        Comment


                          #13
                          Hello WeyldFalcon,

                          Thanks for your reply.

                          You asked for an example and I just grabbed one I had, it was not meant for you to use that in your code as-is. You can always adjust the colors as you wish.

                          Can you confirm that the indicators Autoscale is set to true?
                          Paul H.NinjaTrader Customer Service

                          Comment


                            #14
                            Hello omololu,

                            Thanks for your post.

                            The example posted was not related to any other code posted, the OP asked for an example of Draw.Text that used the autoscale bool.
                            Paul H.NinjaTrader Customer Service

                            Comment


                              #15
                              Auto scale under Visual has a check in the box, and the code says true in the 3rd location of Draw.Text
                              Code:
                              Draw.Text(this, "test" +(CurrentBar), [B]true[/B], EMAChange.ToString("0"+"%"), 0, (Low[0] + (High[1]-Low[1])*1.5), 0, TextColor1, new SimpleFont ("Arial",13), TextAlignment.Center, Brushes.Cyan,Brushes.Yellow,100);

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Barry Milan, Today, 10:35 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post Barry Milan  
                              Started by DJ888, Yesterday, 06:09 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              40 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Today, 08:51 AM
                              2 responses
                              16 views
                              0 likes
                              Last Post bill2023  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              167 responses
                              2,260 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X