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 TradeForge, Today, 02:09 AM
        0 responses
        2 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by elirion, Today, 01:36 AM
        0 responses
        4 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        4 views
        0 likes
        Last Post gentlebenthebear  
        Started by samish18, Yesterday, 08:31 AM
        2 responses
        9 views
        0 likes
        Last Post elirion
        by elirion
         
        Working...
        X