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

3 Bar Line

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

    3 Bar Line

    Hi NT,

    I built a simple script that search for '3 bar triangles'.
    The pattern is formed when a bar[0] is inside the 2-day high/low range.

    Code:
    if ((High[0] < High[1] || High[0] < High[2]) && (Low[0] > Low[1] || Low[0] > Low[2]))
    At the moment, I add a dot under the bar[0] to see it on the chart..

    Code:
    Draw.Dot(this, "LOW" + CurrentBar, true, 0, Low[0] - ((ATR(14))[0]/2), Brushes.Yellow);
    Instead of having this dot, i'd like to have 2 small horizontal lines.... that have the length of the 3 bars, one at the price of the highest high of the 3 bars and one at the lowest low of the 3 bars - i've attached a simple picture to illustrate the desired outcome (red lines)

    What could I replace the Draw.Dot with ?

    Thanks in advance
    AK
    Attached Files

    #2
    Hello,

    Thank you for the post.

    The easiest solution would be to use Lines instead of Dots. The only part that you would need to consider would be when this condition becomes true, at that point where the end and beginning of the line should go.

    You will have access to the high and low of the bars, so the Price is not necessarily a concern. The price for the start bar would be the High or Low with the number of BarsAgo you have determined is the start of the line.

    When the dot is drawn currently, you would likely need to utilize the BarsAgo overload to set a Line a few bars back up till the current bar.


    The Line takes two BarsAgo, 0 can be used to achieve the Current bar. You would just need to determine how many BarsAgo the start of the line should be placed when the condition becomes true.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Draw.Line worked a treat, but only for the latest pattern on the chart for some reason.

      Code:
      Draw.Line(this, "tag1", false, 2, Math.Max(High[1],High[2]), 0, Math.Max(High[1],High[2]), Brushes.Yellow, DashStyleHelper.Solid, 2);
      Draw.Line(this, "tag2", false, 2, Math.Min(Low[1],Low[2]), 0, Math.Min(Low[1],Low[2]), Brushes.Yellow, DashStyleHelper.Solid, 2);
      I suspect the issues lies with the '2' (startBarsAgo) and '0' and (endBarsAgo).
      Any idea what I should replace these values with to allow my script to draw the lines for historical patterns ? I dont have the same issue with Draw.Dot.

      See the screeshot attached, which shows the yellow single dots working fine historically, but my new 3 bar line only worksfor the latest pattern.. if though they are right one after the other in the IF statement..

      Code:
      if ((High[0] < High[1] || High[0] < High[2]) && (Low[0] > Low[1] || Low[0] > Low[2]))
      {
      Draw.Dot(this, "LOW" + CurrentBar, true, 0, Low[0] - ((ATR(14))[0]/2), Brushes.Yellow);	
      						
      Draw.Line(this, "tag1", false, 2, Math.Max(High[1],High[2]), 0, Math.Max(High[1],High[2]), Brushes.Yellow, DashStyleHelper.Solid, 2);
      
      Draw.Line(this, "tag2", false, 2, Math.Min(Low[1],Low[2]), 0, Math.Min(Low[1],Low[2]), Brushes.Yellow, DashStyleHelper.Solid, 2);
      Attached Files

      Comment


        #4
        Hello,

        Thank you for the reply.

        It looks like you are using a single tag name instead of something unique which would only allow one line at a time per tag name.

        Try using:

        Code:
        "tag1" + CurrentBar
        Code:
        Draw.Line(this, [B]"tag1" + CurrentBar[/B], false, 2, Math.Max(High[1],High[2]), 0, Math.Max(High[1],High[2]), Brushes.Yellow, DashStyleHelper.Solid, 2);
        This should allow the script to leave existing lines and draw a new one.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by alifarahani, Today, 09:40 AM
        6 responses
        36 views
        0 likes
        Last Post alifarahani  
        Started by Waxavi, Today, 02:10 AM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by Kaledus, Today, 01:29 PM
        5 responses
        14 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by Waxavi, Today, 02:00 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by gentlebenthebear, Today, 01:30 AM
        3 responses
        17 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X