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 RookieTrader, Today, 09:37 AM
      3 responses
      15 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by kulwinder73, Today, 10:31 AM
      0 responses
      5 views
      0 likes
      Last Post kulwinder73  
      Started by terofs, Yesterday, 04:18 PM
      1 response
      23 views
      0 likes
      Last Post terofs
      by terofs
       
      Started by CommonWhale, Today, 09:55 AM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by Gerik, Today, 09:40 AM
      2 responses
      7 views
      0 likes
      Last Post Gerik
      by Gerik
       
      Working...
      X