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

indicator draw lines with color

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

    indicator draw lines with color

    Can someone help me with this, I have 2 drawn lines with the same start and end bar but with a different color. The first line was drawn for example in bar 65 with green color while the second line was drawn in bar 75 with red color. Now if I scroll back the chart to bar 70 or less I want the second to be behind the first line, the indicator should only show the green line.

    #2
    Hello luxurious_04,

    Thanks for your post.

    If you create a condition that checks if CurrentBar is less than your criteria or less than bar 70, you could have the drawing objects called so one would be over the other, and then in an else statement you can have the lines drawn in another way. Your criteria would have to depend strictly on price movement in OnBarUpdate and could not depend on how you are viewing the chart/where it is scrolled to.

    If you would like to have the same lines drawn but when you are scrolled to a certain point on the chart, change the order in which the lines are displayed, this would have to use custom rendering with SharpDX. You could check if ChartBars.FromIndex/ChartBars.ToIndex is bar 70 or some index offset from your lines, and then based on this check, you can change the way the lines are displayed. Since the criteria for displaying the lines depends on how we are viewing the chart, this sort of rendering would have to be done with OnRender instead of using Drawing Tools.

    For an example on drawing lines with SharpDX, please see the SampleCustomRender example indicator that is included with the platform. Please also see the SharpDX for Custom Rendering guide for more information on using SharpDX.



    Please let me know if I can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks Jim, I could probably add the CurrentBar or trigger bar in the Tag of the line then compare it to the ChartBars.FromIndex/ChartBars.ToIndex.

      Comment


        #4
        In NT7, the two lines have the same x1,y1 and x2, y2 with different colors red and green. Green line was drawn in bar 65 then second line which is Red line was drawn in bar 75 with the same x1,y1 and x2,y2 of the Green line. When I scroll back to bar 70 only Green line will show and if I go scroll forward to bar 75 the Red line will show it will overlapped the Green line. That's what I'm to do in NT8.

        Comment


          #5
          Hello luxurious_04,

          Changing the way the chart is displayed or how objects are displayed based on how the chart is scrolled will need to be done with custom rendering in OnRender.

          I would still advise to create logic to draw these lines in OnRender following logic based on where the lines should reside and where ChartBars.FromIndex/ChartBars.ToIndex is. You could then draw lines with one overlapping the other when those indexes are closer to one line's start/end indexes.

          Please let me know if I can be of further assistance.
          JimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ETFVoyageur, 05-18-2024, 12:45 AM
          12 responses
          62 views
          0 likes
          Last Post ETFVoyageur  
          Started by armybender, 11-16-2023, 08:38 PM
          12 responses
          189 views
          1 like
          Last Post NinjaTrader_RyanS  
          Started by Ryan333, Yesterday, 05:25 PM
          4 responses
          17 views
          0 likes
          Last Post Ryan333
          by Ryan333
           
          Started by wuannetraam, Yesterday, 07:43 AM
          8 responses
          46 views
          0 likes
          Last Post wuannetraam  
          Started by grebow25, Today, 09:20 AM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Working...
          X