• 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

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 quantera, Today, 05:38 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post quantera  
                    Started by ciro1963, Today, 03:58 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post ciro1963  
                    Started by swcooke, Today, 02:48 PM
                    1 response
                    6 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by SOFI777, Today, 01:03 PM
                    5 responses
                    30 views
                    0 likes
                    Last Post SOFI777
                    by SOFI777
                     
                    Started by Gerard111, 09-23-2015, 07:25 AM
                    2 responses
                    1,207 views
                    0 likes
                    Last Post NinjaTrader_ChristopherD  
                    Working...
                    X