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

Problem in drawing a line

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

    Problem in drawing a line

    Dear All,

    I am new in NinjaSceipt. I tried to draw a line using DrawLine() method, but it doesn't work. I didn't see anything drawn on the panel. Why ?

    I write the code below in the Initialize() function:

    DrawLine("aaaa",AutoScale, 100, 1000, 200, 2000, Color.Green, DashStyle.Solid, 2);


    Thanks

    #2
    Hello,

    Thanks for your forum post and welcome to the NinjaTrader forum.

    In initialize the Bar Series objects do not exist yet. Therefor this would need to be moved down to OnBarUpdate(). So that it can be drawn on the chart.

    Also, you will need to add a check in OnBarUpdate() to only draw this once it has 200 bars on the chart or else you will get an error in the log tab in the control center if you run this as is in OnBarUpdate() as OnBarUpdate() starts running from the left of the chart to the right and then starts to run on live data as it comes in.

    Please follow these instructions:



    Let me know if I can be of further assistance.

    Comment


      #3
      Thanks very much for your help Brett.

      I have successful draw the line. Another question is how to draw some more lines on the palen? See the code below:

      if(CurrentBar > 200 && flag){
      DrawLine("aaaa",AutoScale, 100, 1000, 0, 2000, Color.Green, DashStyle.Solid, 2);
      DrawLine("aaaa",AutoScale, 100, 2000, 0, 1000, Color.Blue, DashStyle.Solid, 2);
      flag = false;
      }


      It only shows the second line, how to solve this problem?

      Also, I want to draw a line that indicates the maximun value of a bar segment( for example, 10bars)
      then the first thing I should do is to detect the maximum value of the 10 bars.
      Is there any build in function that I can use to achieve such goal ?
      If not, how to do that ?

      Thanks
      Last edited by keven; 02-16-2011, 09:32 AM.

      Comment


        #4
        Hello,

        This occurs as the tag aaaa is used for each line.

        If the same tag is used it will update the location of the line instead of draw a new one.

        If you always want a new line drawn all the time for example an easy way to do this is.

        DrawLine("aaaa" + CurrentBar,AutoScale, 100, 1000, 0, 2000, Color.Green, DashStyle.Solid, 2);

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ZenCortexCLICK, Today, 04:58 AM
        0 responses
        5 views
        0 likes
        Last Post ZenCortexCLICK  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        172 responses
        2,280 views
        0 likes
        Last Post sidlercom80  
        Started by Irukandji, Yesterday, 02:53 AM
        2 responses
        17 views
        0 likes
        Last Post Irukandji  
        Started by adeelshahzad, Today, 03:54 AM
        0 responses
        5 views
        0 likes
        Last Post adeelshahzad  
        Started by Barry Milan, Yesterday, 10:35 PM
        3 responses
        13 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X