Announcement

Collapse
No announcement yet.

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:	731
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.

    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.

      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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        128 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        73 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        116 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        109 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        88 views
        0 likes
        Last Post CarlTrading  
        Working...
        X