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

Trendlines

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

    Trendlines

    if (DrawTrendlines)
    {
    double y = anchor2Price - ((CurrentBar - anchor2Index) * ((anchor1Price - anchor2Price) / (anchor2Index - anchor1Index)));

    if (Close[1] < y && Close[0] > y)
    {

    Draw.ArrowUp(this, "TrendBreakUp", true, 0, Low[0] - TickSize, Brushes.Green);
    }
    }

    that code work properly but some time that not draw arrow .
    what is wrong

    #2
    Hello yeshujbp,

    Use prints to understand the behavior.

    Below is a link to a forum post on using prints to understand the behavior.


    Are both conditions evaluating as true?

    If you print the Time[0] along with the Low[0] - TickSize within the action block of the condition that triggers the drawing object call, do you see a print for the bar in question?

    I am happy to assist with analyzing the output if you would like to include this along with the code of the print, and the time of the bar in question.


    One note, the tag name of the arrow is not unique on each bar. This means that the object will be updated on a new bar instead of a new object being created.
    From the help guide:
    "2.Set unique tag values for each draw object, unless you intend for new draw objects to replace existing objects with the same tag. A common trick is to incorporate the bar number as part of the unique tag identifier. For example, if you wanted to draw a dot that indicated a buying condition above a bar, you could express it:
    Draw.Dot(this, CurrentBar.ToString() + "Buy", false, 0, High[0] + TickSize, Brushes.ForestGreen);"
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      THANKS FOR REPLY

      Actualy I want to get a point where Trendlines cross any BAR.

      Comment


        #4
        Hello yeshujbp,

        Finding if a point intersects a line between two points would require custom logic.

        The LineAlert indicator for NinjaTrader 7 demonstrated similar logic for finding when the close price intersected a manually drawn line. You can read the logic for this.
        Updated 9-28-11: Used a simpler approach for horizontal lines and improved "no alert" message handling so that these messages should always be correctly removed. ========= This indicator will alert when the most recent bar crosses manually drawn lines. Works on lines, rays, horizontal lines, and extended lines. Apply the indicator to a chart and manually [&#8230;]


        This script does not exist for NinjaTrader 8 as the Alerts window provides this functionality internally in NT8.


        This thread will remain open for any community members that would like to assist you with writing this custom logic.

        You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.


        The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by mmenigma, Today, 02:22 PM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by frankthearm, Today, 09:08 AM
        9 responses
        35 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by NRITV, Today, 01:15 PM
        2 responses
        9 views
        0 likes
        Last Post NRITV
        by NRITV
         
        Started by maybeimnotrader, Yesterday, 05:46 PM
        5 responses
        26 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by quantismo, Yesterday, 05:13 PM
        2 responses
        21 views
        0 likes
        Last Post quantismo  
        Working...
        X