• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Save / Restore an IntervalSelector value

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

    How to Save / Restore an IntervalSelector value

    Hello,

    I wan to save and recover the value of an IntervalSelector.

    I'm trying to set its value in a XElement on Save:

    Code:
    // NTTabPage member. Required for storing elements to workspace
    protected override void Save(XElement element)
    {
    	if (element == null)
    		return;
    
    	// Save the currently selected interval
    	if (intervalSelector != null)
    	{
    		element.Add(new XElement("IntervalValue") {Value = intervalSelector.Interval.Value.ToString()});
    		element.Add(new XElement("IntervalValue2") {Value = intervalSelector.Interval.Value2.ToString()});
    	}
    }
    and later to recover it like that:

    Code:
    protected override void Restore(XElement element)
    {
    	if (element == null)
    		return;
    
    	// Restore the previously selected instrument
    	var intervalValue = element.Element("IntervalValue");
    	var intervalValue2 = element.Element("IntervalValue2");
    	if (intervalValue != null && !string.IsNullOrEmpty(intervalValue.Value) &&
    		intervalValue2 != null && !string.IsNullOrEmpty(intervalValue2.Value))
    		intervalSelector.Interval = new BarsPeriod
    		{
    			Value = Int32.Parse(intervalValue.Value),
    			Value2 = Int32.Parse(intervalValue2.Value)
    		};
    }
    However, it works only when "Duplicate" tab, but not when close / open the add on window.

    How to fix it?
    Last edited by PopovMP; 06-11-2017, 05:54 AM.

    #2
    It appears that this save / restore methods work when we save the workspace

    Comment


      #3
      Hi PopovMP,

      have a look at the "AddOnFramework"-Sample at the very bottom lines. There you can find exactly what you want.

      Comment


        #4
        Hello PopovMP,

        Yes, windows can only save with the workspace when using NinjaScript tools.

        Attached is a simple example that demonstrates.

        GoSPvC is also correct, the Addon Framework NinjaScript Basic demonstrates this as well.
        http://ninjatrader.com/support/helpG...t_overview.htm
        Attached Files
        Last edited by NinjaTrader_ChelseaB; 08-03-2017, 08:29 AM.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ct, Today, 05:31 AM
        0 responses
        1 view
        0 likes
        Last Post ct
        by ct
         
        Started by ketotop7, Today, 03:58 AM
        0 responses
        5 views
        0 likes
        Last Post ketotop7  
        Started by Radiant0, Today, 03:55 AM
        0 responses
        4 views
        0 likes
        Last Post Radiant0  
        Started by pstrusi, Today, 02:21 AM
        0 responses
        5 views
        0 likes
        Last Post pstrusi
        by pstrusi
         
        Started by indy73, Yesterday, 10:52 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_EricB  
        Working...
        X