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 Johnny Santiago, 10-11-2019, 09:21 AM
      95 responses
      6,193 views
      0 likes
      Last Post xiinteractive  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      2 responses
      11 views
      0 likes
      Last Post xiinteractive  
      Started by Irukandji, Today, 09:34 AM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by RubenCazorla, Today, 09:07 AM
      1 response
      5 views
      0 likes
      Last Post RubenCazorla  
      Started by TraderBCL, Today, 04:38 AM
      3 responses
      25 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X