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

Changing the ATR Indicator

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

    Changing the ATR Indicator

    Hi All,

    How would I create an indicator that gives me half the value of the ATR. Everything else stays the same.

    Is there a way of simply using the existing ATR indicator you have, or would it need writing from scratch. If so, how would I do that.

    Many thanks for your help.

    PS. I appreciate I could just load the ATR and do the sum mentally, but as I use it constantly in my trading, to have this "correct" value already there would greatly help.

    #2
    Hello 678Red,

    Welcome to the NinjaTrader forums!

    private double halfATR;
    halfATR = ATR(14)[0] / 2;
    Print(halfATR);

    If you are setting a plot value this would be Value[0] = halfATR;.

    If you are new to programming NinjaScripts, below is a link to a forum post with helpful resources on getting started with NinjaScript and C#.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your help, but to be honest I have no idea what I'm doing here.

      I tried creating a new indicator and entered the code you mentioned in your post, just a load of errors.

      Comment


        #4
        Hello 678Red,

        Make new indicator.

        In State.SetDefaults add:
        AddPlot(Brushes.Blue, "myPlot");

        In OnBarUpdate() add:
        Value[0] = ATR(14)[0] / 2;
        Last edited by NinjaTrader_ChelseaB; 05-09-2022, 08:48 AM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Brilliant. It actually works. many thanks for your help.

          Comment


            #6
            Hi
            I feel dumb here but this does'nt work on my indicator.
            I have set the variable, added the plot and added the value in OnBarUpdate (on first tick of bar) - all compiles and runs but no output?

            Where could I be going wrong.

            Comment


              #7
              Hello Mindset,

              What variable have you set? Are you referring to the Value series for the current bar?

              Are you getting errors in the NinjaScript Output window?

              Do you have more code than what I suggested above?
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by kempotrader, Today, 08:56 AM
              0 responses
              6 views
              0 likes
              Last Post kempotrader  
              Started by kempotrader, Today, 08:54 AM
              0 responses
              4 views
              0 likes
              Last Post kempotrader  
              Started by mmenigma, Today, 08:54 AM
              0 responses
              2 views
              0 likes
              Last Post mmenigma  
              Started by halgo_boulder, Today, 08:44 AM
              0 responses
              1 view
              0 likes
              Last Post halgo_boulder  
              Started by drewski1980, Today, 08:24 AM
              0 responses
              3 views
              0 likes
              Last Post drewski1980  
              Working...
              X