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

making bars invisible and revert back to color

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

    making bars invisible and revert back to color

    Hi,

    I added a button to my chart via an indicator.

    What I want the button to do is:

    if bars are visible - make bars invisible (set barcolors and outline to transparent if there is no other way)

    if bars are invisible - make bars visible (go back to initial parameters as defined in chart properties)

    what whould be the easiest way to do so.

    as always thanks in advance and really appreciate help.

    regards

    #2
    Hello keepsimple,

    Thanks for opening the thread.

    This would be done easiest by saving/restoring the BarBrush the CandleOutlineBrush and replacing them with Brushes.Transparent. If you are doing this from a button, you will have to loop through all bars and modify BarBrushes and CandleOutlineBrushes.

    You will also need to trigger a custom event when changing BarBrushes or CandleOutlineBrushes outside of OnBarUpdate().

    Code:
    TriggerCustomEvent(o =>
    {
    	if(makeTransparent == true)
    	{
    		myCandleOutlineBrush = CandleOutlineBrush;
    		myBarBrush = BarBrush;
                    for(int i = 0; i < CurrentBar; i++)
    		{
    			CandleOutlineBrushes[i]   = Brushes.Transparent;
    			BarBrushes[i] = Brushes.Transparent;
    		}
    	}
    	else
    		for(int i = 0; i < CurrentBar; i++)
    		{
    			CandleOutlineBrushes[i]   = myCandleOutlineBrush;
    			BarBrushes[i] = myBarBrush;
    		}
    }, null);
    I have provided links to the our documentation on the items discussed.

    BarBrush - https://ninjatrader.com/support/help...s/barbrush.htm
    BarBrushes - https://ninjatrader.com/support/help...barbrushes.htm

    CandleOutlineBrush - https://ninjatrader.com/support/help...tlinebrush.htm
    CandleOutlineBrushes - https://ninjatrader.com/support/help...inebrushes.htm

    TriggerCustomEvent() - https://ninjatrader.com/support/help...ustomevent.htm

    Please let me know if I can be of further help.
    Last edited by NinjaTrader_Jim; 11-01-2017, 10:51 AM.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks very much,

      that should do. Wasnt sure about the need to loop, that primarily why I was asking.

      regards

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by michi08, 10-05-2018, 09:31 AM
      5 responses
      741 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by The_Sec, Today, 02:29 PM
      0 responses
      2 views
      0 likes
      Last Post The_Sec
      by The_Sec
       
      Started by tsantospinto, 04-12-2024, 07:04 PM
      4 responses
      62 views
      0 likes
      Last Post aligator  
      Started by sightcareclickhere, Today, 01:55 PM
      0 responses
      1 view
      0 likes
      Last Post sightcareclickhere  
      Started by Mindset, 05-06-2023, 09:03 PM
      9 responses
      261 views
      0 likes
      Last Post ender_wiggum  
      Working...
      X