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 rhyminkevin, Today, 04:58 PM
    1 response
    39 views
    0 likes
    Last Post Anfedport  
    Started by iceman2018, Today, 05:07 PM
    0 responses
    5 views
    0 likes
    Last Post iceman2018  
    Started by lightsun47, Today, 03:51 PM
    0 responses
    7 views
    0 likes
    Last Post lightsun47  
    Started by 00nevest, Today, 02:27 PM
    1 response
    14 views
    0 likes
    Last Post 00nevest  
    Started by futtrader, 04-21-2024, 01:50 AM
    4 responses
    49 views
    0 likes
    Last Post futtrader  
    Working...
    X