Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.TextFixed not showing results

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

    Draw.TextFixed not showing results

    Yesterday I created an indicator that worked. Today it doesn't and I can't figure out why.

    The indicator uses Draw.TextFixed to plot the value of the currently forming bar and the range of the previous bar. It also plots a few other things but the issue is that it will not work if I try to plot the value of the previous bar. I am using a multi-line plot and when I try to utilise the 2nd line (double previous), the plot disappears completely.

    The full code of the indicator is attached.
    This is the code I am using and I have show the troublesome line as a comment with the // thingy in front.

    protected override void OnBarUpdate()
    {
    if (CurrentBar < 5)
    return;

    double now = Math.Abs((High[0] - Low[0])/TickSize);
    //double previous = Math.Abs((High[1] - Low[1])/TickSize);
    double target_1 = Math.Round (((ATR(Fast)[0] / TickSize )*Tgt_1),0) ;
    double target_2 = Math.Round (((ATR(Fast)[0] / TickSize )*Tgt_2),0) ;
    double slow = Math.Round ((ATR(Slow)[0] / TickSize ),0) ;

    Attached Files

    #2
    Hello Kaiviti57,
    Your code seems to be working, please find attached snapshot.
    Click image for larger version

Name:	tgt.jpg
Views:	399
Size:	10.4 KB
ID:	1129589
    Last edited by s.kinra; 11-26-2020, 09:59 PM. Reason: snapshot error

    Comment


      #3
      Hello Kaiviti57,

      Thanks for your post.

      I uncommented your code and added it to an ES 12-20- 1 minute chart and like member s.kinra did not see any issues.

      If the indicator is not working (displaying anything), please check the log tab of the NinjaTrader control center for any related error messages.

      Comment


        #4
        Thanks guys. It is most strange. I did the same thing Paul, and now it is working again. I have no idea why it would not work yesterday. As soon as I uncommented that line and compiled it, all the text would disappear from the chart. It made no difference if it was in the Draw.TextFixed line or not - it would remove all the text!!!

        I even went to the length of rebuilding the indicator several times and did several different things. Every time I uncommented that line of code, it would fail. I thought that maybe an update in software or a clean of my computer by CCleaner had done something. I did a repair on Ninja Trader. Nothing seemed to fix the problem. Then today it is working again.

        Comment


          #5
          Hello Kaiviti57,
          I guess you would have added if (CurrentBar < 5) condition at a later stage with hit & trial. This is required only for your previous (commented line) calculation & CurrentBar < 1 will work for sure. Sometimes due to multiple iterations compiler may cache your incorrect code, so reset the indicator generally solves the issue or you can restart NT8 / PC, nothing else is required as this will clear cache & you get it working. Hope it helps!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          649 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          370 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          576 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X