• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 indy73, Today, 04:42 PM
    0 responses
    9 views
    0 likes
    Last Post indy73
    by indy73
     
    Started by Italianforex, Today, 06:20 AM
    2 responses
    12 views
    0 likes
    Last Post gplatis
    by gplatis
     
    Started by alextrd, Today, 01:51 PM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_JoshG  
    Started by Boonfly8, Today, 12:10 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by NinjaTrader_PaulH, Today, 11:24 AM
    0 responses
    7 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Working...
    X