• 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

  • jengland
    started a topic Automatically mark Price with horizontal line

    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

  • NinjaTrader_ZacharyG
    replied
    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.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by Debayan Sen, Today, 01:50 AM
0 responses
3 views
0 likes
Last Post Debayan Sen  
Started by eleven, Yesterday, 10:03 PM
1 response
9 views
0 likes
Last Post eleven
by eleven
 
Started by tvbecv, Yesterday, 09:23 PM
0 responses
8 views
0 likes
Last Post tvbecv
by tvbecv
 
Started by reedstickets, Yesterday, 08:07 PM
0 responses
9 views
0 likes
Last Post reedstickets  
Started by timko, Yesterday, 07:39 PM
0 responses
5 views
0 likes
Last Post timko
by timko
 
Working...
X