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 judysamnt7, 03-13-2023, 09:11 AM
              4 responses
              53 views
              0 likes
              Last Post DynamicTest  
              Started by ScottWalsh, Today, 06:52 PM
              4 responses
              32 views
              0 likes
              Last Post ScottWalsh  
              Started by olisav57, Today, 07:39 PM
              0 responses
              5 views
              0 likes
              Last Post olisav57  
              Started by trilliantrader, Today, 03:01 PM
              2 responses
              19 views
              0 likes
              Last Post helpwanted  
              Started by cre8able, Today, 07:24 PM
              0 responses
              6 views
              0 likes
              Last Post cre8able  
              Working...
              X