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 CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    213 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    126 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    145 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    229 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    190 views
    0 likes
    Last Post CarlTrading  
    Working...
    X