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

Draw.Text produces inconsistent spacing across dataseries

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

    Draw.Text produces inconsistent spacing across dataseries

    This is a minor annoyance but since I've seen it addressed here over the past few years and as I'm running the latest build (late December) I wanted to bring it to your attention.

    When using Draw.Text to mark my candles according to my trend logic I see varying spacing above the highs and below the lows of my candles.

    Try something similar on a 2-min ES chart:

    Code:
    if (upperTrendMode) {
    Draw.Text(this, 0 + "-series upperTrendMode" + CurrentBars[0], false, label,  indicatorIndex, Highs[0][indicatorIndex] + 1.5 * Instrument.MasterInstrument.RoundToTickSize(TickSize * tickSizeMultiplier), 1, Brushes.White, textFont, TextAlignment.Center, Brushes.SeaGreen, Brushes.DarkOliveGreen, 100);
    } else if (lowerTrendMode) {
    Draw.Text(this, 0 + "-series lowerTrendMode" + CurrentBars[0], false, label,  indicatorIndex, Lows[0][indicatorIndex] - 1.5 * Instrument.MasterInstrument.RoundToTickSize(TickSize * tickSizeMultiplier), -1, Brushes.White, textFont, TextAlignment.Center, Brushes.IndianRed, Brushes.Crimson, 100);
    FYI - tickSizeMultiplier is only used for Forex and on the ES it's set to 1.

    The most recent drawings look correct but the more I scroll backward in time the more the spacing increases. I've used this drawing technique for years and it usually has worked fine for me.

    Any suggestions?

    #2
    Hello molecool,

    Print the values to the output window along with the time of the bar.

    For example:

    Highs[0][indicatorIndex] + 1.5 * Instrument.MasterInstrument.RoundToTickSize(TickSi ze * tickSizeMultiplier)

    Print(string.Format("{0} | Highs[0][indicatorIndex: {1}] + 1.5 * Instrument.MasterInstrument.RoundToTickSize(TickSi ze: {2} * tickSizeMultiplier: {3}): {4} = {5}", Time[0], indicatorIndex, TickSize, tickSizeMultiplier, Instrument.MasterInstrument.RoundToTickSize(TickSi ze * tickSizeMultiplier), (Highs[0][indicatorIndex] + 1.5 * Instrument.MasterInstrument.RoundToTickSize(TickSi ze * tickSizeMultiplier)));

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea - apologies for the belated response but the beginning of the year is always super busy for me.

      Please see the enclosed file. The total always comes out to 0.25.

      If it's not a big then it's most likely due to it being a 2-min chart. As I scroll sideways the total chart range expands/contracts more than with LT charts. Perhaps that's why it 'looks' further away sometimes.

      Not sure if there is an intelligent way of getting that sorted. The one thing I could think of is consider the chart range and then applying some kind of multiplier that's related to that 0.25 value.

      What do you think?
      Attached Files

      Comment


        #4
        Hello molecool,

        This is Jim responding on behalf of Chelsea who is out of the office at this time.

        Looking at your screenshots, the end of the chart screenshot has 36 points displayed on the price scale and the screenshot from a few hours prior has 14 points displayed.

        The screenshot with 36 points visible will have more price levels in view and will effectively have the text displayed "closer" to the bars.

        The screenshot with 14 points visible will have less price levels in view, so the text will appear further away because there is greater visual distance between each tick.

        We do offer overloads to specify a pixel offset and this would have more consistent visual spacing than offsetting by TickSize, which will adjust spacing as the price scale changes.

        Draw.Text overloads/documentation - https://ninjatrader.com/support/help...?draw_text.htm

        We look forward to assisting.
        JimNinjaTrader Customer Service

        Comment


          #5
          Hi Jim - appreciate your quick response. Yes, I am familiar with pixel offset but how does that differ from the 25 pixels that were the results of my formula? Or what does that 25 represent if it's set as they y distance?

          Anyway right now my offset is set to +1 and -1 respectively (above and below bar). You are saying that switching my formula with the pixel offset would produce the desired result?

          Thanks,

          MIchael

          Comment


            #6
            Hello Michael,

            In your snippet, you are using a pixel offset of -1, and the test is drawn to the price level calculated by "Lows[0][indicatorIndex] - 1.5 * Instrument.MasterInstrument.RoundToTickSize(TickSi ze * tickSizeMultiplier)"

            This would mean the text is drawn relative to where the price level is, which changes based on the price scale.

            If you used Lows[0][0] and a negative pixel offset value, this will draw the text below Low[0] by that number of pixels, and this will not change as the price scale changes.

            I've attached a video demonstration to help visualize.

            https://drive.google.com/file/d/1c6K...w?usp=drivesdk

            Let us know if there is anything else we can do to help.
            JimNinjaTrader Customer Service

            Comment


              #7
              Thanks Jim - that was an awesome video and dedicated to me to boot! :-)

              Given your awesome demonstration I believe I'm probably better off with price offset as the right/recent side of the chart is where I direct most of my attention.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by r68cervera, Today, 05:29 AM
              0 responses
              2 views
              0 likes
              Last Post r68cervera  
              Started by geddyisodin, Today, 05:20 AM
              0 responses
              3 views
              0 likes
              Last Post geddyisodin  
              Started by JonesJoker, 04-22-2024, 12:23 PM
              6 responses
              33 views
              0 likes
              Last Post JonesJoker  
              Started by GussJ, 03-04-2020, 03:11 PM
              12 responses
              3,239 views
              0 likes
              Last Post Leafcutter  
              Started by AveryFlynn, Today, 04:57 AM
              0 responses
              6 views
              0 likes
              Last Post AveryFlynn  
              Working...
              X