Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.Text not showing up

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

    Draw.Text not showing up

    Hi all, I am new to this and just trying to start out really small, I replicate the TickCounter indicator and try to have a new one to appear on the last bar, but seems like I cant' get it to show up. I can compile the code OK but can't seem to see anything. Please take a look at the last 2 lines. What am I doing wrong? thanks

    Code:
    protected override void OnBarUpdate()
    {
    double periodValue = (BarsPeriod.BarsPeriodType == BarsPeriodType.Tick) ? BarsPeriod.Value : BarsPeriod.BaseBarsPeriodValue;
    double tickCount = ShowPercent ? CountDown ? (1 - Bars.PercentComplete) * 100 : Bars.PercentComplete * 100 : CountDown ? periodValue - Bars.TickCount : Bars.TickCount;
    
    string tick1 = (BarsPeriod.BarsPeriodType == BarsPeriodType.Tick
    || ((BarsPeriod.BarsPeriodType == BarsPeriodType.HeikenAshi || BarsPeriod.BarsPeriodType == BarsPeriodType.Volumetric) && BarsPeriod.BaseBarsPeriodType == BarsPeriodType.Tick) ? ((CountDown
    ? NinjaTrader.Custom.Resource.TickCounterTicksRemain ing + tickCount : NinjaTrader.Custom.Resource.TickCounterTickCount + tickCount) + (ShowPercent ? "%" : ""))
    : NinjaTrader.Custom.Resource.TickCounterBarError);
    
    //Draw.TextFixed(this, "NinjaScriptInfo", tick1, TextPosition.TopRight, ChartControl.Properties.ChartText, ChartControl.Properties.LabelFont, Brushes.Transparent, Brushes.Transparent, 0);
    Draw.Text(this,"customTickCount",tick1,0,1000);
    Draw.Text(this, "customTickCount2", ticker1, 10, 1000, ChartControl.Properties.ChartText);
    }

    #2
    Hello thaison316,

    Thanks for your post and welcome to the NinjaTrader forums.

    The Draw.Text() method will draw the text relative to an X (time) and Y (Price).

    In this example: "Draw.Text(this,"customTickCount",tick1,0,1000 );" will draw the text on the current bar at a price level of 1000.

    In this example "Draw.Text(this, "customTickCount2", ticker1, 10, 1000, ChartControl.Properties.ChartText);" will draw the text 10 bars ago, at a price level of 1000. I did not see ticker1 defined or assigned a value.

    When applying a developing script (indicator or Strategy), I recommend checking the "Log" tab of the Ninjatrader control center for any related error messages. If there are errors, the indicator's output (text in this case) would not appear on the chart.

    If there are no errors then the likely issue here is the price level likely does not relate to the instrument you are looking at.

    As a suggestion, you might want to try: Draw.Text(this,"customTickCount",tick1,0, High[0] + 5 * TickSize); // draw text 5 ticks above the high of the bar.

    Alternately you could use Low[0] - 5 * TickSize (feel free to adjust the "5" to any value you want to clearly see the tick count).

    Forum member soon123's suggestion to add a CurrentBar to the tagname will not be helpful unless you want to see the tick count placed on the chart by every bar. For your understanding, when you use the same tagname each time you draw the text, the previous text will be removed so that only one text will be shown Using +CurrentBar would make a "unique" tag name thus the previous text will not be removed. By using a unique tagname and drawing on every bar, would use a lot of resources and may impact Ninjatrader performance.

    Comment


      #3
      thank you for the response.
      I also have to add this
      Code:
      if (CurrentBar <= 10) {return;}
      or else I will get an indexing error. Thanks for the advice on the Log tab, I can also ask why
      Code:
      5 * TickSize
      , what is the purpose of * ticksize?

      I ended up doing it this way because using the 0 (BarsAgo), I can't seem to shift the text to the right.
      Code:
      if (CurrentBar <= 10) {return;}
      
      //Draw.Text(this,"tag1",tickCount.ToString(),0,High[0] + 5 * TickSize,Brushes.White);
      //Reference https://ninjatrader.com/support/forum/forum/ninjatrader-8/strategy-development/1039688-draw-text-example-not-working#post1039725
      Draw.Text(this,"tag2",false,tickCount.ToString(),T ime[0].AddMinutes(90),Low[0]-2,50,Brushes.White,myFont,System.Windows.TextAlign ment.Left,null,null,0);

      Comment


        #4
        Hello thaison316,

        Thanks for your reply.

        TickSize is the smallest increment for a given instrument so it allows you to apply to any instrument and draw the text the same distance from the bar. You can certainly use a price value if you prefer.
        Reference: https://ninjatrader.com/support/help.../?ticksize.htm

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        599 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        344 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        558 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        557 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X