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

Selectable View for different Plots

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

    Selectable View for different Plots

    Dear,

    I am translating and indicator from NT7 to NT8 and I am almost done (after some efforts).
    I have still only one small issue to translate in order to have it t 100%, i hope someone could help me.

    Here the original NT7 code
    Code:
    		protected override void Initialize()
    		{	Overlay = true;
    			Add(new Plot(new Pen(valueColor,	2),	PlotStyle.Line, "Value"));
    			Add(new Plot(new Pen(angleColor, 	2), PlotStyle.Line, "Angle"));
    			Add(new Plot(new Pen(triggerColor, 	2), PlotStyle.Line, "Trigger"));
    		}
    		//ENDInitialize
    		protected override void OnStartUp()
    		{	switch(view)	//
    			{	case Views.Indicator:			{	Plots[0].Pen=new Pen(Color.Lime);		Plots[1].Pen = new Pen(Color.Transparent);	Plots[2].Pen = new Pen(Color.Transparent);	}	break;
    				case Views.Trigger:				{	Plots[0].Pen=new Pen(Color.Transparent);Plots[1].Pen = new Pen(Color.Transparent);	Plots[2].Pen = new Pen(Color.Lime);			}	break;
    				case Views.Angle:				{	Plots[0].Pen=new Pen(Color.Transparent);Plots[1].Pen = new Pen(Color.Lime);			Plots[2].Pen = new Pen(Color.Transparent);	}	break;
    			}	if (view!=Views.Indicator||indicate==Indicates.RSI) ScaleJustification=ScaleJustification.Left; else ScaleJustification=ScaleJustification.Right;
    		}//ENDOnStartup

    Here my attemps to translate

    Code:
    protected void Initialize(){ ....
    
    				// Adds a plot to our NinjaScript Indicator
    				IsOverlay									= true;
    				AddPlot(new Stroke(Brushes.Blue), PlotStyle.Line, "Value");
    				AddPlot(new Stroke(Brushes.Transparent), PlotStyle.Line, "Angle");
    				AddPlot(new Stroke(Brushes.Transparent), PlotStyle.Line, "Trigger");
    
    			switch(view)
    			{	case Views.Indicator:			{	PlotBrushes[0][0] = Brushes.Lime;		PlotBrushes[1][0] = Brushes.Transparent;	PlotBrushes[2][0] = Brushes.Transparent;	}	break;
    				case Views.Trigger:				{	PlotBrushes[0][0] = Brushes.Transparent;PlotBrushes[1][0] = Brushes.Transparent;	PlotBrushes[2][0] = Brushes.Lime;			}	break;
    				case Views.Angle:				{	PlotBrushes[0][0] = Brushes.Transparent;PlotBrushes[1][0] = Brushes.Lime;			PlotBrushes[2][0] = Brushes.Transparent;	}	break;
    			}	if (view!=Views.Indicator||indicate==Indicates.RSI) ScaleJustification=ScaleJustification.Left; else ScaleJustification=ScaleJustification.Right;

    At the end, the idea is to have the selector (see screen) and plot in color only one of the three indicator. The other two should plot as Transparent (shouldn't be visible). The result I am having are the three plots in colour.

    Any further information needed, please ask. Will be really nice if someone could help me with this structure.

    Thank you in advance!
    Attached Files
    Last edited by Estorki; 08-26-2017, 11:27 AM.

    #2
    Originally posted by Estorki View Post
    Dear,

    I am translating and indicator from NT7 to NT8 and I am almost done (after some efforts).
    I have still only one small issue to translate in order to have it t 100%, i hope someone could help me.

    Here the original NT7 code
    Code:
            protected override void Initialize()
            {    Overlay = true;
                Add(new Plot(new Pen(valueColor,    2),    PlotStyle.Line, "Value"));
                Add(new Plot(new Pen(angleColor,     2), PlotStyle.Line, "Angle"));
                Add(new Plot(new Pen(triggerColor,     2), PlotStyle.Line, "Trigger"));
            }
            //ENDInitialize
            protected override void OnStartUp()
            {    switch(view)    //
                {    case Views.Indicator:            {    Plots[0].Pen=new Pen(Color.Lime);        Plots[1].Pen = new Pen(Color.Transparent);    Plots[2].Pen = new Pen(Color.Transparent);    }    break;
                    case Views.Trigger:                {    Plots[0].Pen=new Pen(Color.Transparent);Plots[1].Pen = new Pen(Color.Transparent);    Plots[2].Pen = new Pen(Color.Lime);            }    break;
                    case Views.Angle:                {    Plots[0].Pen=new Pen(Color.Transparent);Plots[1].Pen = new Pen(Color.Lime);            Plots[2].Pen = new Pen(Color.Transparent);    }    break;
                }    if (view!=Views.Indicator||indicate==Indicates.RSI) ScaleJustification=ScaleJustification.Left; else ScaleJustification=ScaleJustification.Right;
            }//ENDOnStartup
    Here my attemps to translate

    Code:
    protected void Initialize(){ ....
    
                    // Adds a plot to our NinjaScript Indicator
                    IsOverlay                                    = true;
                    AddPlot(new Stroke(Brushes.Blue), PlotStyle.Line, "Value");
                    AddPlot(new Stroke(Brushes.Transparent), PlotStyle.Line, "Angle");
                    AddPlot(new Stroke(Brushes.Transparent), PlotStyle.Line, "Trigger");
    
                switch(view)
                {    case Views.Indicator:            {    PlotBrushes[0][0] = Brushes.Lime;        PlotBrushes[1][0] = Brushes.Transparent;    PlotBrushes[2][0] = Brushes.Transparent;    }    break;
                    case Views.Trigger:                {    PlotBrushes[0][0] = Brushes.Transparent;PlotBrushes[1][0] = Brushes.Transparent;    PlotBrushes[2][0] = Brushes.Lime;            }    break;
                    case Views.Angle:                {    PlotBrushes[0][0] = Brushes.Transparent;PlotBrushes[1][0] = Brushes.Lime;            PlotBrushes[2][0] = Brushes.Transparent;    }    break;
                }    if (view!=Views.Indicator||indicate==Indicates.RSI) ScaleJustification=ScaleJustification.Left; else ScaleJustification=ScaleJustification.Right;
    At the end, the idea is to have the selector (see screen) and plot in color only one of the three indicator. The other two should plot as Transparent (shouldn't be visible). The result I am having are the three plots in colour.

    Any further information needed, please ask. Will be really nice if someone could help me with this structure.

    Thank you in advance!
    Plots[0].Brush = Brushes.Lime; not PlotBrushes[0][0] = Brushes.Lime; et.c.

    Comment


      #3
      Thank you for your reply. I am trying to figure out why is still not working.
      Last edited by Estorki; 08-27-2017, 05:11 AM.

      Comment


        #4
        Originally posted by Estorki View Post
        Thank you for your reply. I am trying to figure out why is still not working.
        Is there an error message in your log?

        Comment


          #5
          Hello Estorki,

          In the code you have posted for NinjaTrader 8 it appears the Initialize() override is still being used.

          May I confirm this code is being added to OnStateChange() for NT8?


          In what State is this code triggered?

          If you print the value of the PlotBrush after it is set, are you finding the color printed is the expected color?
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by bmartz, 03-12-2024, 06:12 AM
          4 responses
          31 views
          0 likes
          Last Post bmartz
          by bmartz
           
          Started by Aviram Y, Today, 05:29 AM
          4 responses
          11 views
          0 likes
          Last Post Aviram Y  
          Started by algospoke, 04-17-2024, 06:40 PM
          3 responses
          28 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by gentlebenthebear, Today, 01:30 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by cls71, Today, 04:45 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X