Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Automatically mark Price with horizontal line

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

    Automatically mark Price with horizontal line

    Hi All

    Bit of a newbie with writing indicators but is there a simple way of marking price at **.00 **.20 **.50 and **.80 automatically? with sound as well would be nice but not fussed!

    Any answers in advance are appreciated.

    Thanks in advance

    #2
    Hello jengland,

    Thank you for your inquiry and welcome to the NinjaTrader Support Forum!

    Just to clarify, are you wishing for a horizontal line to be drawn each time the closing price of your instrument hits the prices of **.00, **.20, **.50, and **.80 and an alert to be made?

    Here's a quick example of how to do this below:
    Code:
    private int lineNumber = 1; // just for purposes of differentiating lines and alerts through their tags
    
    protected override void OnBarUpdate()
    {
         if (Close[0].ToString("0.00").Contains(".00") || Close[0].ToString("0.00").Contains(".20") || Close[0].ToString("0.00").Contains(".50") || Close[0].ToString("0.00").Contains(".80"))
         {
              DrawLine("line" + lineNumber, 1,Close[0], -1, Close[0], Color.Blue);
              Alert("alert"+ lineNumber, NinjaTrader.Cbi.Priority.High, "Reached price", "Alert1.wav", 10, Color.Black,Color.Yellow);
              lineNumber++; // increment lineNumber by 1 for a unique tag for each line drawn
         }
    }
    I would suggest reading through the help guide at this link for a few educational resources on how to program your own strategies and indicators: http://ninjatrader.com/support/helpG..._resources.htm

    The alphabetical reference section in the help guide as well will allow you to look up the various syntax I used and assist with explaining what each does: http://ninjatrader.com/support/helpG..._reference.htm

    The ToString() and Contains() methods are methods that are not unique to NinjaScript, but are a part of C#.

    For more information about ToString(), please take a look at this link: http://www.dotnetperls.com/tostring

    For more information about Contains(), please take a look at this link: http://www.dotnetperls.com/contains

    Please, let me know if I may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    668 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    377 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    110 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    575 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    580 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X