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

Absolutely weird!!!!

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

    Absolutely weird!!!!

    I don't know if anyone can help with this. This is the weirdest experience I've ever had coding. I have 2 lines of code that are exactly the same. One will execute part of the code and one will not execute any of the code even though the Print() states the condition is true! How can this happen???????
    I had the 2nd condition in another section my indicator and it just was drawing the arrow. I ran prints that came back true, but no arrow. I thought maybe there was a stray bool somewhere so I took that line of code and stuck it right underneath the line that was drawing accurately. Still it wouldn't work. They are the exact condition!!
    I then tried placing additional drawing methods in the working code and those wouldn't draw!!!. I commented out the drawing method that was working and compiled. This time nothing worked. I placed the previously working drawing method back in, compiled, and it worked, but only that method(DrawDiamond).
    After typing the above I tried other Draw methods wondering if the DrawDiamond() was working when the other weren't and sure enough it draws in both conditions, but the other methods will not draw. What is going on? Here is the code.

    if(dema_Up_slow_background > 50 && Close[0] >= channel_upper_line && Close[1] < channel_upper_line)
    {
    DrawDiamond("Whats Up" + CurrentBar, true, 0, High[0] + .15, Color.DarkOrchid);//Working
    DrawArrowUp("going Up", true, 0, Low[0] - .3, Color.DarkTurquoise); //Not Working
    channel_break_up = true;
    DrawText("Low", "Low", correction_low_1_bar, Low[correction_low_1_bar] - .25, Color.DodgerBlue);//Not Working
    DrawDiamond("Screwed Up" + CurrentBar, true, 0, High[0] + .35, Color.Black);//Working
    }
    if(dema_Up_slow_background > 50 && Close[0] >= channel_upper_line && Close[1] < channel_upper_line)
    {
    DrawArrowUp("going Up", true, 0, Low[0] - .3, Color.DarkTurquoise);//Not working
    Print(Time[0]);
    Print("Condition true");
    DrawDiamond("screwed Up" + CurrentBar, true, 0, Low[0] - .15, Color.DarkOrchid);//Working
    DrawDot("xxxxx", true, 0, Low[0] - .3, Color.Bisque);//Not working
    }

    Any help insights would be greatly appreciated.

    #2
    Ok I figured it out. I forgot to add "+ CurrentBar" to the tag on all those draw methods that didn't work. Problem solved.

    Comment


      #3
      I need to reopen this issue. I added "+ CurrentBar" to the tags of all my draw objects and everything worked fine until today. Now some objects aren't printing at all. I know no one can see my code. I'm just wondering if there is a know issue in NT7 with perhaps having to many draw objects on the screen.

      Comment


        #4
        Ok. I guess I just need a board to state my issue so I can figure it out myself. I was using DrawArrowUp() with DrawText() and using the same tag names. Apparently that is a no no. I gave everything a unique name and everything checked out. I probably just didn't realize this was happening before when I thought it was working right.

        Comment


          #5
          Hello CaptainAmericaXX,

          Thanks for your posts!

          Yes, each draw object must have a unique tag name as the first thing that happens when drawing is to first see if a tag name already exists and if so the object with that tag name is removed and the new tag name is drawn.

          Having a lot of drawing objects can slow things down a bit. While your view of the chart is a limited data set, objects with unique tags are still created for the off screen data so that if you scroll back they are available to be drawn.

          If you find that you can live with less than all objects drawn, another "technique" you might consider is limiting the number of objects you draw by using a limited number of unique tag names. For example, if you wanted to only show the latest 20 draw objects you would use a counter to create the unique tag name:

          if (condition to draw)
          {
          tagCount++; // increment tag counter first
          DrawDot("myDot"+tagCount, ....);
          if (tagCount >= 20)
          {
          tagCount = 0; // reset counter when at 20 tags
          }
          }

          tagCount is an int that is initialized to 0. You can, of course, change the count limit to be as you wish.
          Paul H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by TheMarlin801, 10-13-2020, 01:40 AM
          20 responses
          3,914 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by timmbbo, 07-05-2023, 10:21 PM
          3 responses
          150 views
          0 likes
          Last Post grayfrog  
          Started by Lumbeezl, 01-11-2022, 06:50 PM
          30 responses
          805 views
          1 like
          Last Post grayfrog  
          Started by xiinteractive, 04-09-2024, 08:08 AM
          3 responses
          11 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by Johnny Santiago, 10-11-2019, 09:21 AM
          95 responses
          6,194 views
          0 likes
          Last Post xiinteractive  
          Working...
          X