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 rtwave, 04-12-2024, 09:30 AM
    4 responses
    29 views
    0 likes
    Last Post rtwave
    by rtwave
     
    Started by yertle, Yesterday, 08:38 AM
    7 responses
    28 views
    0 likes
    Last Post yertle
    by yertle
     
    Started by bmartz, 03-12-2024, 06:12 AM
    2 responses
    21 views
    0 likes
    Last Post bmartz
    by bmartz
     
    Started by funk10101, Today, 12:02 AM
    0 responses
    6 views
    0 likes
    Last Post funk10101  
    Started by gravdigaz6, Yesterday, 11:40 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X