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 sjsj2732, Yesterday, 04:31 AM
    0 responses
    22 views
    0 likes
    Last Post sjsj2732  
    Started by NullPointStrategies, 03-13-2026, 05:17 AM
    0 responses
    280 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    279 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    130 views
    1 like
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    90 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Working...
    X