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

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 RookieTrader, Today, 09:37 AM
                    1 response
                    10 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by alifarahani, Today, 09:40 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post alifarahani  
                    Started by Gerik, Today, 09:40 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post Gerik
                    by Gerik
                     
                    Started by KennyK, 05-29-2017, 02:02 AM
                    3 responses
                    1,283 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by AttiM, 02-14-2024, 05:20 PM
                    11 responses
                    185 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Working...
                    X