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

Using ATR value in my indicator

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

    Using ATR value in my indicator

    Hi.

    And first of all happy holidays!

    I built an indicator which draws vertically stacked numbers in my chart. The distance between the numbers is something I can adjust in my indicator by changing the "dista" value (see below) from for example 10 to 16, 24 or higher depending on market movements.

    DrawText("collab5", false, "15", 1, Lows[0][1]-(dista*1)*TickSize, 0, uplr, new Font ("Arial", 7, FontStyle.Bold),StringAlignment.Near, uplr, Color.Empty, 0);
    DrawText("collab6", false, "30", 1, Lows[0][1]-(dista*1.5)*TickSize, 0, uplr, new Font ("Arial", 7, FontStyle.Bold),StringAlignment.Near, uplr, Color.Empty, 0);
    DrawText("collab7", false, "60", 1, Lows[0][1]-(dista*2)*TickSize, 0, uplr, new Font ("Arial", 7, FontStyle.Bold),StringAlignment.Near, uplr, Color.Empty, 0);

    Now my question. Is there a simple way to use the value from the ATR indicator in my indicator to replace "dista" so that the distance practically adjusts itself based on market movement rather than me having to do it manually.

    If so, could you provide a sample code/snippet with which I could work as I am not really a programmer.

    sandman




    #2
    Hello sandman,

    Thanks for your post.

    Here is a simple example, using an ATR of 1 period (so it is the range of the bar).

    DrawText("test"+CurrentBar, High[0].ToString(), 0, Low[0] - ATR(1)[0], Color.Blue); // draw the bar's high value text at the low price minus the ATR of the bar. You may want to experiment with other values of ATR period but a 1 period allows the text to remain that bars length below the bar. See attached example:

    Click image for larger version

Name:	sandman-5.PNG
Views:	564
Size:	86.0 KB
ID:	1082036
    Last edited by NinjaTrader_PaulH; 12-27-2019, 10:44 AM. Reason: Removed NT8 example and screenshot, replaced with same but in NT7 format.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello sandman,

      Just a quick note, I originally posted an NT8 example and have since changed that for NT7, sorry for any confusion.
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Thank you Paul. I'll experiment with what you provided. Looks good.

        sandman

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bortz, 11-06-2023, 08:04 AM
        47 responses
        1,607 views
        0 likes
        Last Post aligator  
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        9 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        19 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        6 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        15 views
        0 likes
        Last Post Javierw.ok  
        Working...
        X