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:	568
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 pibrew, Today, 06:37 AM
        0 responses
        4 views
        0 likes
        Last Post pibrew
        by pibrew
         
        Started by rbeckmann05, Yesterday, 06:48 PM
        1 response
        14 views
        0 likes
        Last Post bltdavid  
        Started by llanqui, Today, 03:53 AM
        0 responses
        6 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        11 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        16 views
        0 likes
        Last Post AaronKoRn  
        Working...
        X