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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    31 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    19 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    9 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    17 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    20 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X