Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem drawing dot (or other chartmarker) between two bars

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

    Problem drawing dot (or other chartmarker) between two bars

    The following code (almost always) draws a dot halfway between the previous bar and current bar at the low of the current bar.

    Code:
    int IntervalValue = BarsPeriod.Value;
    double IntervalValueDouble = Convert.ToDouble(IntervalValue);
    DateTime CurrentBarDT = Bars.GetTime(CurrentBar);
    DateTime HalfwayBetweenBarsDT = CurrentBarDT.AddMinutes(-IntervalValueDouble/2);
    
    Draw.Dot(this, CurrentBar.ToString()+"Dot", false, HalfwayBetweenBarsDT, Low[0], Brushes.Yellow, true);
    The only problem occurs on the day following a holiday. For instance, Monday February 20 was a holiday (Washington's Birthday). If you apply this code to an intraday chart and look at February 21, you will see that the first dot of February 21 is not drawn halfway between the last bar of Friday February 17 and the first bar of Tuesday February 21. Instead, the dot is drawn directly over the first bar of February 21.

    I've added the following code...

    Code:
    Print("CurrentBar = " + CurrentBar);
    Print("HalfwayBetweenBarsDT = " + HalfwayBetweenBarsDT);
    ...and looked at the Output Window for February 21 and can see that the value of HalfwayBetweenBarsDT is 2/21/2017 9:35:00 AM (using a 5-Minute chart). The time of 9:35:00 tallies with the value of HalfwayBetweenBarsDT on the first bar of other days.

    Is there anyway to correct this problem?

    Is there a better/easier way to draw a dot between two bars without using DateTime? Perhaps some pixel offset?

    #2
    Hello h1000,

    I have tested your code but I was not able to reproduce the behavior.

    Below is a link to a video of the test.
    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    May I confirm I have taken the correct steps to test?

    If you take the same steps as in this video, are you getting different behavior?

    Attached is the script I have tested.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      ChelseaB, thanks for the reply--I've been busy with other matters and didn't see your reply until today. The screencast video was certainly useful to get your point across.

      It seems to me that you're doing everything correctly to test it.

      In the video, I notice that you are using ES 06-17. Could you test it with a stock, for instance APPL. The holiday period for the stock--including the weekend--amounted to no trading on Feb 18, Feb 19, Feb 20.

      On my chart, the dot is still being placed in-line with the first bar of the day on Feb 20.

      Could this have anything to do with the trading hours template being used? I have the data series on my chart set to use US Equities RTH.

      Comment


        #4
        Hello h1000,

        Thanks for the tip about the instrument.

        I was able to reproduce when viewing this on an aapl 30 minute chart on Feb 20th.

        I've reported the behavior to our development and I will update this thread once I have more information or when/if I receive a tracking ID.

        Thank you for reporting this behavior so that it may be addressed.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello h1000,

          Our development has let me know the behavior appears to be caused by incorrect Trading Hours templates and they are in the process of getting these corrected.

          This issue is being tracked with ID #NTEIGHT-11775.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          576 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 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
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X