Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exposing Values

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

    Exposing Values

    Good morning,

    I have and indicator with 2 different time frames. I am trying to have 2 different Values called, one for each time frame.

    Under addplot() in the language reference it show and example using Values[0] and then Values[1]. This example below seems to work fine as an indicator.


    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1)
    {
    if(High[1][0] > High[1][1])
    {
    Value[0][0] = 1;
    }
    else
    {
    Value[0][0] = 0;
    }
    }

    if (BarsInProgress == 2)
    {
    if(High[2][0] > High[2][1])
    {
    Value[1][0] = 2;
    }
    else
    {
    Value[1][0] = 0;
    }
    }​
    }


    [Browsable(false)]
    [XmlIgnore]
    public Series<double> MyPlot
    {
    get { return Values[0]; }
    }


    [Browsable(false)]
    [XmlIgnore]
    public Series<double> MyPlot2
    {
    get { return Values[1]; }
    }



    But when I go to reference this in a strategy I can't seem to get the strategy to recognize Values[1]. Example below of strategy. Any help would be greatly appreciated. Thanks, Ryan


    protected override void OnBarUpdate()
    {​
    if(MyIndicator1[0] == 1)
    {
    EnterLong();
    }
    if(MyIndicator1[0] == 2)
    {
    EnterLong();
    }
    ​​​​​​​}​
    Last edited by Tonkingrf1551; 08-18-2023, 08:11 AM.

    #2
    Hello Tonkingrf1551,

    From the strategy you would want to reference the plot.

    private MyCustomIndicatorName MyIndicator;

    In OnBarUpdate():

    Print( MyIndicator.MyPlot2[0] );

    Note, that plot series will only be synchronized with the primary series.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    72 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    39 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X