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

Button on toolbar

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

    #16
    Originally posted by GeorgeW View Post
    Thanks for this utility.
    I have adapted it for an indicator and it compiles, but my indicator does not show the plot, I use it jut to show some DrawText. I have the button on my taskbar, but it does not currently toggle on and off the DrawText. I think I need to adjust the section of the code below. Any ideas how I should adjust it for DrawText? Thanks!

    Code:
    //For toggle
    			private void hideshow(object s, EventArgs e)
    			{
    				if ( show == false ) 
    				{
    					Plots[0].Pen = new Pen(Color.Transparent);
    					show = true;
    					button.ForeColor = Color.Silver;
    				}
    				else
    				{
    					Plots[0].Pen = new Pen (PlotColor,1);
    					show = false;
    					button.ForeColor = Color.Blue;
    				}
    				
    				ChartControl.ChartPanel.Refresh();
    				
    			}
    Code:
    //For toggle
    			private void hideshow(object s, EventArgs e)
    			{
    				if ( show == false ) 
    				{
    					DrawText("wtf", ...);
    					show = true;
    					button.ForeColor = Color.Silver;
    				}
    				else
    				{
    					RemoveDrawObject("wtf");
    					show = false;
    					button.ForeColor = Color.Blue;
    				}
    				
    				ChartControl.ChartPanel.Refresh();
    				
    			}

    Comment


      #17
      Thanks Koganam, that's worked fine for the final BarsAgo DrawText. But the DrawText is also applied to earlier bars, and those are not being toggled on and off.

      The original code was:
      Code:
      DrawText (TagdiffVol1 + CurrentBar, "A"+"\n"+diffVol+"\n"+wTSum+"\n"+a1+"\n"+aPB+"\n"+a3.ToString(), 0, High[0] + 6 * TickSize, Color.Black);
      The code inserted to toggle it on and off, but only toggles off the one at BarsAgo[0] is:
      Code:
      DrawText ("wtf", "A"+"\n"+diffVol+"\n"+wTSum+"\n"+a1+"\n"+aPB+"\n"+a3.ToString(), 0, High[0] + 6 * TickSize, Color.Black);
      I have tried a for loop for the other bars, but it is not working:
      Code:
      if ( show == false ) 
      {
      for (int x = CurrentBar; x > CurrentBar - 256; x--)
        {
        DrawText ("wtf", "A"+"\n"+diffVol+"\n"+wTSum+"\n"+a1+"\n"+aPB+"\n"+a3.ToString(),      x, High[0] + 6 * TickSize, Color.Black);
        }
      	show = true;
      	button.ForeColor = Color.Silver;
      }
      I have also tried inserting the original DrawText arguments without the "+CurrentBar" after the tag, before the new DrawText code, but that has not worked.

      Comment


        #18
        Originally posted by GeorgeW View Post
        Thanks Koganam, that's worked fine for the final BarsAgo DrawText. But the DrawText is also applied to earlier bars, and those are not being toggled on and off.

        The original code was:
        Code:
        DrawText (TagdiffVol1 + CurrentBar, "A"+"\n"+diffVol+"\n"+wTSum+"\n"+a1+"\n"+aPB+"\n"+a3.ToString(), 0, High[0] + 6 * TickSize, Color.Black);
        The code inserted to toggle it on and off, but only toggles off the one at BarsAgo[0] is:
        Code:
        DrawText ("wtf", "A"+"\n"+diffVol+"\n"+wTSum+"\n"+a1+"\n"+aPB+"\n"+a3.ToString(), 0, High[0] + 6 * TickSize, Color.Black);
        I have tried a for loop for the other bars, but it is not working:
        Code:
        if ( show == false ) 
        {
        for (int x = CurrentBar; x > CurrentBar - 256; x--)
          {
          DrawText ("wtf", "A"+"\n"+diffVol+"\n"+wTSum+"\n"+a1+"\n"+aPB+"\n"+a3.ToString(),      x, High[0] + 6 * TickSize, Color.Black);
          }
        	show = true;
        	button.ForeColor = Color.Silver;
        }
        I have also tried inserting the original DrawText arguments without the "+CurrentBar" after the tag, before the new DrawText code, but that has not worked.
        Sorry, but I only answered the question that you asked, about how to modify a particular block of code for drawing instead of plotting.

        I am unaware of your larger purpose, and this post does not explain it. It is a piecemeal, made of code snippets without telling us what the intended effect is supposed to be. If you want to remove all draw objects, the command is RemoveDrawObjects(), or else iterate though all IText objects into a collection, and use their tags to delete them in a second pass. If you want to make them invisible, you will have to iterate through them and turn them transparent.

        It is easier to help if the requirements are more clearly stated.

        Comment


          #19
          Ok, sorry about the lack of explanation.

          Basically I have an indicator which draws some calculations to several bars on the chart. I want to make them all transparent at certain times by using the toggle on off button, whilst leaving any other indicators drawn to the chart unaffected. Currently the code switches on and off the last calculation on the chart, and then as I toggle on and off with Market Replay running, it keeps moving that calculation to later bars on the chart.

          Comment


            #20
            Originally posted by GeorgeW View Post
            Ok, sorry about the lack of explanation.

            Basically I have an indicator which draws some calculations to several bars on the chart. I want to make them all transparent at certain times by using the toggle on off button, whilst leaving any other indicators drawn to the chart unaffected. Currently the code switches on and off the last calculation on the chart, and then as I toggle on and off with Market Replay running, it keeps moving that calculation to later bars on the chart.
            That would require you to iterate through all DrawObjects, find the relevant IText objects and change their color to transparent. You would run that code instead of the RemoveDrawObject() code. To turn the text back on, you would do the opposite, iterating through and turning the colors back on, and adding any other IText objects as they come due.

            Comment


              #21
              Ok, thanks, Koganam. There is an example in the NT help manual, so I will see if I can follow it.

              Comment


                #22
                Originally posted by GeorgeW View Post
                Ok, thanks, Koganam. There is an example in the NT help manual, so I will see if I can follow it.
                You mean on how to iterate over the DrawObjects?

                Comment


                  #23
                  Yes. If I understand it correctly, I think example #3 here https://ninjatrader.com/support/help...ub=Drawobjects and reply #6 to the thread here http://ninjatrader.com/support/forum...ad.php?t=48502 are what I need. I just have to work out how to link it to the button.

                  Comment


                    #24
                    Originally posted by GeorgeW View Post
                    Yes. If I understand it correctly, I think example #3 here https://ninjatrader.com/support/help...ub=Drawobjects and reply #6 to the thread here http://ninjatrader.com/support/forum...ad.php?t=48502 are what I need. I just have to work out how to link it to the button.
                    Yes, those about cover it.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by funk10101, Today, 12:02 AM
                    1 response
                    10 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by GLFX005, Today, 03:23 AM
                    1 response
                    6 views
                    0 likes
                    Last Post NinjaTrader_Erick  
                    Started by nandhumca, Yesterday, 03:41 PM
                    1 response
                    12 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by The_Sec, Yesterday, 03:37 PM
                    1 response
                    11 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by vecnopus, Today, 06:15 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post vecnopus  
                    Working...
                    X