• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position of DrawText on 2nd Panel

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

    Position of DrawText on 2nd Panel

    Hello,

    Is it possible to position text above volume bars on a 2nd panel? I have calculated Time & Sales blocks which I would like to be above the volume bars, but they are hidden behind the bars after using DrawOnPricePanel = false in the Initialize() method.

    Thanks.

    #2
    Hello George, and thank you for your question.

    The attached indicator, which is provided for educational value, will plot the closing price at the top of each volume bar. The key to this is sending in the correct value for the Y value. You will need to send in a volume value plus an offset in order to plot the way you would desire as your y value argument to DrawText.

    Please let us know if there are any other ways we can help.
    Attached Files
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      I am having a problem with a DrawText not being written directly above the price bars on my chart. The issue is that the Time & Sales block starts on the FirstTickOfBar and appears on the chart as it increments, but its position then becomes fixed, while the price bar continues to move right until the bar has closed. Using CalculateOnBarClose == true, in the if statement does not work as that also alters the computation to a cumulative one instead of showing just the increment for the individual bar. If I press F5 the historical DrawText is relocated to directly over the bar, but it takes time for the chart to refresh, so that is not practical.

      The indicator is based on a slight addition I have made to the GomDeltaVolume indicator from here

      This is the DrawText part of the code:

      Code:
      			if (volume >=30)
      			{
      			blockcountbuy++ ;
      			DrawText (Tagblockcountbuy1 + CurrentBar, blockcountbuy.ToString(), 0, High[0] + 4*TickSize, Color.Black);//Display above price bars
      //			DrawText (Tagblockcountbuy1 + CurrentBar, blockcountbuy.ToString(), 0, VOL()[0] + 20, Color.Black); //Display above Vol bars
      			}
      Any ideas?
      Thanks.

      Comment


        #4
        Hello GeorgeW,

        Are you filtering out so that the DrawText does not call except on FirstTickOfBar? If you are not, since CurrentBar will remain the same throughout the bar, the tag will remain the same, and your text will drift to the right.

        Would it be possible to receive a stripped down code sample containing your entire OnBarUpdate method? Thanks in advance, I believe with this information we should be able to find a solution quickly.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          I am filtering out with FirstTickOfBar in the OnBarUpdate method, but the DrawText appears in the OnMarketData method where I understand FirstTickOfBar does not work, and I have tried it and get no results. I have attached the exported file. The one concerned is GomDeltaVolume02.

          Thank you.
          Attached Files

          Comment


            #6
            Hello George,

            I am attaching a copy of your script which I believe will address your query. In essence, I am saving a copy of FirstTickOfBar so that it will continue working outside of OnBarUpdate, freeing you up to update your DrawText wherever you would like. I tried to make my annotations obvious, but in case they were not I am including a difference file as well.

            Please let us know if there is any other way we can help.
            Attached Files
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              Thanks for your help on this, JessicaP. I have tested the new one, and whilst it now writes the block counts above the bars, all of them are now 2, instead of the actual value. I'll have a look through the code to see if I can identify the problem.

              Comment


                #8
                Hello,

                I am still having an issue with the calculation from my indicator lining up directly above bar[0]. The problem is as follows:

                CalculateOnBarClose = False; The calculation is correct, but it stops at the left of bar[0] where it started counting, and bar[0] continues shifting to the right until complete.

                CalculateOnBarClose = True; The calculation for bar[0] which is not yet complete, starts & completes above bar[1], so once the first two bars have completed, the value for each subsequent bar ends up on bar[1], even though barsAgo = 0 in the DrawText code.

                So the problem is one of how do you tie an indicator value to above bar[0] if CalculateOnBarClose = False; and bars are not set to equal spacing, so the bar continues moving to the right until complete?

                Any ideas would be appreciated.

                Thanks.

                Comment


                  #9
                  Hello GeorgeW,

                  I believe I understand what you are describing. I am preparing another sample and will get back to you when I have more information.
                  Jessica P.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello GeorgeW,

                    You can achieve the result you are after by adding another boolean, currentlyUpdating, and an integer, barToStop . In OnMarketData, currentlyUpdating should be set to true whenever savedFirstTickOfBar is set to true, and barToStop should be set to CurrentBar at this time. currentlyUpdating should then be set to false when CurrentBar is greater than barToStop. Finally, you will then test for currentlyUpdating rather than savedFirstTickOfBar.

                    Please let us know if there are any other ways we can help.
                    Jessica P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by SAILIKITY, 05-22-2019, 05:41 PM
                    1 response
                    2 views
                    0 likes
                    Last Post NinjaTrader_PaulH  
                    Started by rmillar, 01-09-2019, 06:02 PM
                    6 responses
                    58 views
                    1 like
                    Last Post eDanny
                    by eDanny
                     
                    Started by mlarocco, Today, 11:39 AM
                    4 responses
                    19 views
                    0 likes
                    Last Post mlarocco  
                    Started by roblogic, Today, 11:19 AM
                    2 responses
                    14 views
                    0 likes
                    Last Post roblogic  
                    Started by saeed, Today, 10:17 AM
                    8 responses
                    39 views
                    0 likes
                    Last Post NinjaTrader_Kate  
                    Working...
                    X