Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to change instrument on chart by code

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

    how to change instrument on chart by code

    I am writing an indicator (of class Indicator).
    I'd like to know if it is possible to change the underlying instrument of an indicator by code. For example, lets say I have this indicator object currently works on instrument X. Now I need to work on instrument Y but as Y hasn't been loaded to the chart window by user, I want to make use of the indicator on X but change the instrument to Y. I'm not sure how it can be done though.
    Thanks.

    #2
    Hello emilien,

    Thanks for writing in.

    You will not be able to change the primary data series of an indicator indicator through a chart. This can be done manually within NinjaScript, however.

    Within NinjaScript, you may add an additional Data Series to a strategy or indicator to perform calculations on a data series other than the primary one set by the chart or window.

    There is a sample strategy that outlines this which may be of use to you:

    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


    Please also take the time to read the documentation for the components listed within as well as the documentation on creating NinjaScript for Multi-Time Frame & Instruments:



    If you have any further questions, please don't hesitate to ask.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    82 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    43 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    56 views
    0 likes
    Last Post CarlTrading  
    Working...
    X