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

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 Waxavi, Today, 02:00 AM
    0 responses
    2 views
    0 likes
    Last Post Waxavi
    by Waxavi
     
    Started by elirion, Today, 01:36 AM
    0 responses
    4 views
    0 likes
    Last Post elirion
    by elirion
     
    Started by gentlebenthebear, Today, 01:30 AM
    0 responses
    4 views
    0 likes
    Last Post gentlebenthebear  
    Started by samish18, Yesterday, 08:31 AM
    2 responses
    9 views
    0 likes
    Last Post elirion
    by elirion
     
    Started by Mestor, 03-10-2023, 01:50 AM
    16 responses
    391 views
    0 likes
    Last Post z.franck  
    Working...
    X