Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to expose non-series indicator data?

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

    How to expose non-series indicator data?

    Hi
    I would like some help exposing indicator data to calling strategies. My knowledge of how properties work is not thorough enough and I'd appreciate any advice.
    My indicator creates a list of objects whose properties I want to access from one or more strategies (in addition to series values). This is what I've tried. It compiles but I don't get the data I expect.
    In the indicator file, outside the indicator class, but within the NinjaScript.Indicator namespace, I define a class SDZone, which has several properties I want strategies to access.


    Instances of SDZone are created in the indicator and added to a list of SDZone defined in the indicator.
    Code:
    List<SDZone> zoneList
    …
     zoneList.Add( new SDZone(...) );
    I have made zoneList a property of the indicator.
    Code:
    [Browsable(false)]
     [XmlIgnore]
     public List<SDZone> zoneList
     { get; set; }
    In the strategy, I create a List<SDZone> stratZoneList, and I assign it the indicator property zoneList.
    Code:
    private List<SDZone> stratZoneList;
     …
     stratZoneList = indicator.zoneList;
    Within the strategy, I hoped to be able to access the contents of the list created in the indicator like this:
    Code:
    foreach ( SDZone z in stratZoneList )
     {
    if ( z == null )
    
        Print( "z == null" );
      else
    
        Print( "This is z: " + z.sdZoneProp1.ToString() );
     }
    However, although z is never null, its count is always 0.


    Any help would be welcome.
    Cheers
    Tony

    #2
    Hi

    I have answered my own question now, and I thought it might be useful to share it.
    Note: I'm using NT8 Beta 7

    Two key points:

    1. My strategy doesn't use the series values of the indicator so I didn't call them. However, if they are not called none of the indicator data is updated. I resolved this by simply assigning the current indicator value to a temporary variable within OnBarUpdate() before any other indicator data is used.

    2. You can't just assign a list to a new one and expect the contents to be accessible. I resolved this within the strategy by using the indicator list property directly, e.g.
    Code:
    [SIZE=2]foreach ( SDZone z in indicator.zoneList )
    {
       if ( z == null )
          Print( "z == null" );
       else
          Print( "This is z: " + z.sdZoneProp1.ToString() );
    }[/SIZE]
    Cheers
    Tony
    Last edited by Jellybean; 01-05-2016, 01:50 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    557 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X