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 not working on a stack of panels

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

    Draw.Text not working on a stack of panels

    Hello,

    I made a simple script(attached) to show that Draw.Text does not display when the indicator is loaded on a multi-panel chart.
    A video showing this behavior can be downloaded from https://app.box.com/s/pgin5wchp7vy0ehxyyi2ydae0cq63ffv

    Any suggestions? Is there anything in the code that is not right? Thank you.

    NT 8.0.19.1 64-bit
    WIndows 7
    Attached Files
    Last edited by utilizator; 11-04-2019, 04:57 PM.

    #2
    Hello utilizator,

    Thank you for your note.

    It's right about the end of our support day today, however, I'll take a look at this first thing tomorrow and get back to you.

    Thanks for your patience, I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello utilizator,

      Thank you for your reply.

      I think you may be running into an issue with using (CurrentBar - redLine.StartAnchor.SlotIndex) when the text is updated - with multiple data series there can be differing numbers of bar slots and that can throw the display off. I think you'll find if you scroll forward from the current price a bit that you'll see the text somewhere offscreen. Try using (CurrentBar - redLine.StartAnchor.DrawnOnBar + 20) instead - that should draw the text where you expected in relation to the current bar regardless of available slots.



      Please let us know if we may be of further assistance to you.
      Kate W.NinjaTrader Customer Service

      Comment


        #4
        Thank you Kate, your solution worked.

        Comment


          #5
          Beside hardcoding the '20' value in

          // update the text along with the line
          T2Text = Draw.Text(this,T2Text.Tag,T2Text.DisplayText,
          // (int)(CurrentBar - redLine.StartAnchor.SlotIndex), // barsAgo

          (int)((CurrentBar - redLine.StartAnchor.DrawnOnBar)+20), // here, CurrentBar == redLine.StartAnchor.DrawnOnBar
          redLine.StartAnchor.Price); // price

          is there a way to get it from redLine ?

          redLine=Draw.Line(this, redLine.Tag,
          20,Close[0]/* start */,
          5, Close[0], /* end */
          redLine.Stroke.Brush);

          Comment


            #6
            Hello utilizator,

            Thank you for your reply.

            Since it's the same value you're using in both, why not just use a variable for both? Set it to myVariable = 20 and then use the variable in both places?

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Thank you Kate. Of course, but this is a simplified example, and I would like to avoid using new additional storage variables. I understand there is not a straightforward way to get '20' from redLine's anchor, correct?

              Comment


                #8
                Hello utilizator,

                Thank you for your reply.

                You could use redLine.startBarsAgo in lieu of using a variable. However, a variable may make it easier to remember that those two spots are using the same value.

                Please let us know if we may be of further assistance to you.
                Kate W.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you ! Actually it was absoluteBar = (<ChartAnchor>.DrawnOnBar - <ChartAnchor>.BarsAgo )

                  Code:
                   [COLOR=#006400]// update the line with the incoming price[/COLOR]
                              redLine=Draw.Line(this, redLine.Tag,
                                                  20,Close[0][COLOR=#006400]/* start */,[/COLOR]
                                                  5, Close[0], [COLOR=#006400]/* end */[/COLOR]
                                                  redLine.Stroke.Brush);
                  
                  [COLOR=#006400]// update the text along with the line[/COLOR] 
                              T2Text = Draw.Text(this,T2Text.Tag,T2Text.DisplayText,
                  [COLOR=#006400]//                (int)(CurrentBar - redLine.StartAnchor[/COLOR].[COLOR=#FF0000]SlotIndex[/COLOR][COLOR=#006400]), // barsAgo[/COLOR]
                                  CurrentBar - (redLine.StartAnchor.[COLOR=#FF0000]DrawnOnBar[/COLOR]-redLine.StartAnchor.[COLOR=#FF0000]BarsAgo[/COLOR]),  
                  
                                  redLine.StartAnchor.Price);
                  Last edited by utilizator; 11-08-2019, 04:31 AM.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Stanfillirenfro, Today, 07:23 AM
                  9 responses
                  23 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by George21, Today, 10:07 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post George21  
                  Started by DayTradingDEMON, Today, 09:28 AM
                  2 responses
                  16 views
                  0 likes
                  Last Post DayTradingDEMON  
                  Started by navyguy06, Today, 09:28 AM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by cmtjoancolmenero, Yesterday, 03:58 PM
                  8 responses
                  32 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X