Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Calling on an indicator value (external symbol)

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

    Calling on an indicator value (external symbol)

    Hi,

    How do I call an idicator value from another symbol?
    Lets' say I am building an indicator and applying it to chart of Wheat.
    Lets say that the indicator is X+Y... and Y is the moving average of CL (crude oil).

    I have already added the data series:

    Code:
    else if (State == State.Configure)
    			{
    				AddDataSeries("CL 08-17", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last);
    			}
    But in the OnBarUpdate section, how to call a CL indicator value ?

    Thanks
    AK
    Last edited by akvevo; 06-22-2017, 05:06 PM.

    #2
    Hello akvevo,

    Thanks for your post.

    When you add another data series (from another instrument) the added data series is referenced by its BarsArray[] index. the chart bars are BarsArray[0], the first added data series is BarsArray[1]. You can also reference by using the plurals of price such as Closes[][] or Lows[][] when the first index is the bars array and the 2nd index would be the bar of interest of the bar's array. For example Closes[0][0] refers to the charts bars currentbar. From your example, Lows[1][0] would be the CLs current bar low.

    If, for example, you wanted to use a 20 period SMA from CL, it could be coded as:
    SMA(Closes[1], 20)[0] where Closes[1] points to the close price type of the CL and [0] would be the current bar SMA of the 20 period CL data.

    There are a number of important concepts to review and they are well structured in the helpguide in this section: http://ninjatrader.com/support/helpG...nstruments.htm We highly recommend reading the entire section in order as this will build upon examples that should clarify how you need to code a multi time frame or multi series ninjascript strategy or indicator.
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mikey_, 03-23-2024, 05:59 PM
    3 responses
    49 views
    0 likes
    Last Post Sam2515
    by Sam2515
     
    Started by f.saeidi, Today, 12:14 PM
    7 responses
    17 views
    0 likes
    Last Post f.saeidi  
    Started by Russ Moreland, Today, 12:54 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by philmg, Today, 12:55 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by TradeForge, 04-19-2024, 02:09 AM
    2 responses
    32 views
    0 likes
    Last Post TradeForge  
    Working...
    X