Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Where should ChildIndicator Calculate property be set?

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

    Where should ChildIndicator Calculate property be set?

    NT Forum,

    In the NT8 Language reference - OnStateChange(), the tips section states:
    Scripts that require Calculate to be set by the developer must set this property in State.Historical in order to ensure that if this script is a child (hosted) that the parent.Calculate property which is adopted by the child is overridden again.

    With this knowledge, is the below code snippet ill-advised?
    Code:
    public class HostIndicator : Indicator
    {
     private ChildIndicator _childIndicator;
     protected override void OnStateChange()
     {
      ...
      else if (State == [B]State.Configure[/B])
      {
       _childIndicator = new ChildIndicator();
       _childIndicator.Calculate = this.Calculate;
      }
     }
    }
    Should the ChildIndicator be instantiated in State.Configure and its Calculate property be set in State.Historical?
    Should the ChildIndicator be instantiated and set in State.Historical?
    Is State.DataLoaded also ill-advised? (Embedded indicators within a strategy - Calculate property)

    Thanks
    Shannon

    #2
    Hello Shansen,

    Thank you for your post.

    You would instantiate in Configure, generally you would set Calculate in Historical. However, are you trying to override the child indicator's Calculate that is set in Historical in it's own code? I do not believe this would be advisable as the child could still wind up overriding this.
    DataLoaded would not be ill-advised, you just need to keep in mind this is before Historical - so trying to override Calculate in DataLoaded would not be the recommended means.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ghoul, Today, 06:02 PM
    2 responses
    12 views
    0 likes
    Last Post ghoul
    by ghoul
     
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    44 views
    0 likes
    Last Post jeronymite  
    Started by Barry Milan, Yesterday, 10:35 PM
    7 responses
    20 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by AttiM, 02-14-2024, 05:20 PM
    10 responses
    180 views
    0 likes
    Last Post jeronymite  
    Started by DanielSanMartin, Yesterday, 02:37 PM
    2 responses
    13 views
    0 likes
    Last Post DanielSanMartin  
    Working...
    X