• 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

condition to the stock indicator "Current Day OHL"

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

    condition to the stock indicator "Current Day OHL"

    hello, help solve the problem, i need to add a condition to the stock indicator "Current Day OHL" - a candition that displays a horizontal line on tha the chart.
    Condition :
    if the current value of the minimum or maximum of the day (LOW/HIGH) did not change a certain number of bars (no update high /low for min X bars = double MinBars) - DrawLine, this line is stay on history.
    Logic is to see previos Day Low or High on the chart.

    Something like this
    If (current High > Minbars)
    {
    DrawLine.
    }

    Please help with logic, in example.
    Thanks.

    #2
    Hello memonolog,

    Thanks for your post.

    Please note that we do not provide coding for clients and expect you to develop this on your own. To assist we direct you to methods in the help guide which contain simple examples of use. For your condition, I can provide you with a direction that you would need to develop the specific code for.

    To draw a line you would use the Draw.Line() method, here is a link to the help guide that shows the parameters required and the options for drawing the line: https://ninjatrader.com/support/helpGuides/nt8/en-us/?draw_line.htm

    One way to accomplish your goal of checking for a change in the high or low, would be to compare the current value [0] to the previous bar value [1] of the particular plot of the indicator. If the values are not equal then you have a new high (or low). When the new high (or low) is detected you can save the current bar number into an integer variable. You can then check the value of the variable against the current bar number going forward. On each new bar the difference between the variable and the current bar is the number of bars ago where the change occurred and this is what you can use for your X bars.

    In pseudo code for the high side it would look something like:

    if (currentdayhigh[0] not equal to currentdayhigh[1])
    {
    lastHighchangebar = current bar // save the current bar number when new high found
    }

    if (Current bar minus lastHighChange == X bars)
    {
    Drawline(...);
    }

    You would, of course, need to create the specific code and test this out to see if it meets your needs. If you have not used the strategy builder, you may want to use that to create this and then do a "view code" to see the actual code created which you can then copy into your script.

    If you would like this created for you, we can provide references to 3rd party programmers.

    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NinjaCustomer, Today, 12:29 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Started by smgrvd, Today, 12:08 AM
    0 responses
    4 views
    0 likes
    Last Post smgrvd
    by smgrvd
     
    Started by ronaldgreene828, Yesterday, 07:50 PM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_EricB  
    Started by nailz420, 07-17-2019, 08:38 AM
    2 responses
    13 views
    0 likes
    Last Post nailz420  
    Started by bouncetherubble, Yesterday, 06:56 PM
    0 responses
    6 views
    0 likes
    Last Post bouncetherubble  
    Working...
    X