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

NT7 Multiple OnMarketData on one indicator

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

    NT7 Multiple OnMarketData on one indicator

    I made four separate indicators, all calculate a similar result with slight variations. They all work fine. Each uses:

    protected override void OnMarketData(MarketDataEventArgs e)
    My goal is to combine all four into one indicator, which means I need four OnMarketData on one indicator. I changed all variables in the OnMarketData script and changed the "e" at the end of EventArgs. I still get errors. The error I get is

    'indicator already defines a member called OnMarketData with the same parameter type.'

    Then when I try to use only one "protected override void OnMarketData(MarketDataEventArgs e)" and run the other 3 scripts under the one OnMarketData, again all the variables are unique, the error is

    'the name 'variable' does not exist in the current context'. The variable it's referring to is the unique name I give the "e" after EventArgs.

    This has nothing to do with the math of the code, that's all fine. I just need to know how to run these scripts on one indicator.

    Thank you.

    #2
    Hello imalil,

    Thank you for writing in.

    You can only have one OnMarketData() overridel in your indicator.

    With a multi-time frame/multi-instrument script, OnMarketData() will be called for all unique instruments in your strategy. Use the BarsInProgress to filter the OnMarketData() method for a specific instrument. (BarsInProgress will return the first BarsInProgress series that matches the instrument for the event).

    Please take a look at the help guide at this link for more information about OnMarketData(): https://ninjatrader.com/support/help...marketdata.htm

    For more information about working with multiple instruments and/or multiple timeframes in a script, please take a look at this help guide link: https://ninjatrader.com/support/help...nstruments.htm

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by kaywai, 09-01-2023, 08:44 PM
    5 responses
    601 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by xiinteractive, 04-09-2024, 08:08 AM
    6 responses
    22 views
    0 likes
    Last Post xiinteractive  
    Started by Pattontje, Yesterday, 02:10 PM
    2 responses
    16 views
    0 likes
    Last Post Pattontje  
    Started by flybuzz, 04-21-2024, 04:07 PM
    17 responses
    230 views
    0 likes
    Last Post TradingLoss  
    Started by agclub, 04-21-2024, 08:57 PM
    3 responses
    17 views
    0 likes
    Last Post TradingLoss  
    Working...
    X