Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

When changes in State.SetDefaults should takes effect at plots?

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

    When changes in State.SetDefaults should takes effect at plots?

    Code:
    protected override void OnStateChange()
    	{
    		if (State == State.SetDefaults)
    		{
    
    			Stroke my_stroke = new Stroke( new Brushes.Black), DashStyleHelper.Solid,  1 );
    			AddPlot( my_stroke, PlotStyle.Line, "SomePlot");
    		}
    If I change SomePlot color or DashStyle, I can see effect on chart only after removing indicator from chart and add it again.

    Is the way to see changes just after compile and reload NinjaScript on chart by F5?

    P.S. In NT7 I did any plots changes in OnStartUp() method - it takes effect immediately - It was very fast and convenient.

    P.P.S. I use very "heavy" indicator on 10 charts simultaneously. And it is awful work to remove indicator from all charts and to put it again.
    Last edited by fx.practic; 08-21-2016, 06:20 AM.
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    #2
    Here is answer how to change Plots dashstyle "on the go":

    Code:
    if (State == State.Configure)
    {
         Plots[5].DashStyleHelper = DashStyleHelper.Dot;
    }
    But how can I change plot's thickness and color "on the go" ?
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    Comment


      #3
      Hello,

      Regarding only seeing the changes made when re applying the indicator, this would be expected.

      Any items in the OnStateChange you will generally need to remove and re add the item to see the changes reflected. This was also the same case for NinjaTrader 7 and its Initialize override. Using the OnStartUp for the plots would have been the suggested area to do any changes needed after Initialize which is called by the F5 reload. Historical is likely the suggested state for changes to be made after the fact in NT8.

      To set this from OnBarUpdate or after the initial states, one way could be to assign a new Pen when needed.

      Here is an example of retaining the color while changing the size of the Pen:

      Code:
      Plots[0].Pen = new Pen(Plots[0].Pen.Brush, 12);
      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        Almost obvious answer. Thanks a lot!
        fx.practic
        NinjaTrader Ecosystem Vendor - fx.practic

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by schmidtbc16, Today, 03:36 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by RT001, Today, 03:25 PM
        2 responses
        11 views
        0 likes
        Last Post RT001
        by RT001
         
        Started by mbrandau, Today, 01:58 PM
        5 responses
        32 views
        0 likes
        Last Post mbrandau  
        Started by remcovdmeulen, Today, 02:15 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Jim  
        Started by gbrad, Today, 09:57 AM
        7 responses
        14 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X