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 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.
    Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


    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 TradeForge, Today, 02:09 AM
          0 responses
          0 views
          0 likes
          Last Post TradeForge  
          Started by Waxavi, Today, 02:00 AM
          0 responses
          2 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by elirion, Today, 01:36 AM
          0 responses
          4 views
          0 likes
          Last Post elirion
          by elirion
           
          Started by gentlebenthebear, Today, 01:30 AM
          0 responses
          4 views
          0 likes
          Last Post gentlebenthebear  
          Started by samish18, Yesterday, 08:31 AM
          2 responses
          9 views
          0 likes
          Last Post elirion
          by elirion
           
          Working...
          X