Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

plotting dots on backtesting charts

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

    plotting dots on backtesting charts

    is this the correct code to plot dots on the backtesting charts?


    if (ToTime(Time[0]) >= 930000 && ToTime(Time[0]) <= 160000)
    {
    DrawDot("My dot" + CurrentBar, 0, 0, Color.Blue);
    }


    any reason why it's not working? thanks

    #2
    a) it's always a good idea to check the logs for funny messages
    b) please see here on how to debug your indicator/strategy http://www.ninjatrader-support.com/v...ead.php?t=3418
    c) curious: why would you want to draw a dot at y=0 of your price chart?

    Comment


      #3
      actually, i really don't...

      I just want to be able to see a line from one time to another time...
      just a simple line or dot..
      is this not possible in backtesting mode? couldn't find an example to draw a simple line in backtesting charts.

      Originally posted by NinjaTrader_Dierk View Post
      a) it's always a good idea to check the logs for funny messages
      b) please see here on how to debug your indicator/strategy http://www.ninjatrader-support.com/v...ead.php?t=3418
      c) curious: why would you want to draw a dot at y=0 of your price chart?

      Comment


        #4
        Drawing works in backtest as well as realtime. I suggest starting your indicator/strategy simple as possible and then adding your logic step by step to understand where it breaks.

        Comment


          #5
          Originally posted by NinjaTrader_Dierk View Post
          Drawing works in backtest as well as realtime. I suggest starting your indicator/strategy simple as possible and then adding your logic step by step to understand where it breaks.
          do you have an example of just drawing a line from say 9:30am to 11:00am? Just a simple 2 line code. I'm still a newbie at coding. Trying to understand the basics. I went through the help and sometimes there just isn't enough examples for me to grasp the logic.

          I'd appreciate it. Thanks

          Comment


            #6
            Please see here on how to draw a line: http://www.ninjatrader-support.com/H.../DrawLine.html

            Comment


              #7
              Here is more info: http://www.ninjatrader-support.com/v...ead.php?t=3419

              Comment


                #8
                yeah that's the example I saw..
                I really don't get what X and Y coordinates are for...

                I just want to plot dots from one time to another...

                I tried putting

                If (ToTime(Time[0])==93000)
                DrawLine("tag1", 0, 0, 0, 10, Color.LimeGreen, DashStyle.Dot, 2);


                I do not see a dot at 93000...
                I wish there were more examples.

                Originally posted by NinjaTrader_Dierk View Post
                Please see here on how to draw a line: http://www.ninjatrader-support.com/H.../DrawLine.html

                Comment


                  #9
                  Why don't you just try
                  Code:
                  DrawDiamond("Down Diamond" + CurrentBar, 0, SMA(20)[0], Color.Magenta);
                  as per sample I referenced.

                  Note: Leave all time based filtering for the start and just try the line above.

                  Comment


                    #10
                    Originally posted by z32000 View Post
                    is this the correct code to plot dots on the backtesting charts?


                    if (ToTime(Time[0]) >= 930000 && ToTime(Time[0]) <= 160000)
                    {
                    DrawDot("My dot" + CurrentBar, 0, 0, Color.Blue);
                    }


                    any reason why it's not working? thanks

                    Sure there's a reason.

                    You have to tell the draw methods where to draw.

                    Your line or dot is 'there' but you can't see it because of your invalid x/y co-ordinates.
                    'barsAgo' is the x co-ord .. which is the bar you want to draw from. 0 is the current bar.
                    'y' is the vertical position .. ie the price level you want to draw at.

                    Your code told it to draw a line from Bar 0, Price 0... probably not what you wanted

                    Each of the Draw... has an example of how to do this
                    For example .. right out of the help text ...
                    Code:
                    // Paints a red dot on the current bar 1 tick below the low 
                    DrawDot("tag1", true, 0, Low[0] - TickSize, Color.Red);
                    So something like this may work for you
                    Code:
                    if (ToTime(Time[0]) >= 930000 && ToTime(Time[0]) <= 930100)
                    { 
                          double mylinevalue = Close[0] ;     
                          // Remember the close price at the 9:30 bar 
                          // A dot will be drawn using this value.
                    }
                    if (ToTime(Time[0]) >= 930000 && ToTime(Time[0]) <= 160000)
                    {
                        // Draw a dot on the current bar (bar '0') using the closing price we stored at 9:30 for the 'y' value
                    
                         DrawDot("My dot" + CurrentBar, 0, mylinevalue ,Color.Blue);   
                     }
                    Don't worry about your programming experience. We all start someplace, and graphing x/y co-ordinates can be confusing.
                    Fwiw .. Most charting programs do this a similar way..
                    Last edited by zoltran; 11-24-2007, 01:03 PM.

                    Comment


                      #11
                      Thanks for both your help...I'm learning as I ago and I've learned a lot thus far. This board is great!

                      Anyway, I gave this code a try and it worked

                      if (ToTime(Time[0]) >= 100000 && ToTime(Time[0]) <= 120000)
                      {
                      DrawDiamond(
                      "Diamond" + CurrentBar, 0, Close[0] , Color.Magenta);
                      (sorta still don't get why you're adding a string to a int value of the CurrentBar....but it works though and that's all that matters.

                      I'm actually trying to get two futures charts to appear at the same time in the backtesting charts section...
                      I'd like to see where I made a trade on one and then be able to draw lines on the other... is it possible to see this in the backtesting charts?

                      Comment


                        #12
                        The Strategy Analyzer will only be able to chart your primary bar series. You can draw things based on values from the secondary bar series, but you will not be able to see a chart of the secondary bar series directly from the Strategy Analyzer.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Yes, there's a misplaced zero in the time.

                          I think you want 093000, not 930000.
                          Originally posted by z32000 View Post
                          is this the correct code to plot dots on the backtesting charts?

                          if (ToTime(Time[0]) >= 930000 && ToTime(Time[0]) <= 160000)
                          {
                          DrawDot("My dot" + CurrentBar, 0, 0, Color.Blue);
                          }

                          any reason why it's not working? thanks
                          Yes, there's a misplaced zero in the time.

                          I think you want 093000, not 930000... the time's just never going to get to 93:00:00.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          571 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          330 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          101 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          548 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          549 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X