Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

trigger MarketDataEvent

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

    trigger MarketDataEvent

    I need to trigger from my code the MarketDataEvent or call the OnMarketData method. Can anyone tell me how to trigger the event or what are the meanings of the parameters in the constructor of MarketDataEventArgs?

    Thanks

    #2
    Hello,

    The OnMarketData is triggered when data is recieved from the data feed provider. Any code placed in OnMarketData() { } will then run.

    If this is not what you need can you please clarify what it is your trying to do so that I may further assist.
    BrettNinjaTrader Product Management

    Comment


      #3
      yes, I know, and I use it for that, but in other situations I need to do some things that I also do in OnMarketData, that´s why I was wondering if I can call this method from my own code and in one sentence differenciate if is a call because of a MarketData event or a call from my own code and that will allow me to reuse some code.

      Comment


        #4
        Hello,

        I do not believe this is supported. However I will have my product manager review this ticket to double check this.

        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment


          #5
          You will not be able to trigger such an event. If you have parts of your code in OnMarketData() that you want to use elsewhere too instead of putting it in OnMarketData() you should put it in its own method. Then in OnMarketData() you can call that method. This will also allow you to call this method when you are not in OnMarketData() and from other locations as well.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            but, for example if I call OnmarketData from one of my methods like this

            Code:
            [FONT=Courier New] [/FONT]
            MarketDataEventArgs e=[FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] MarketDataEventArgs([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2].MarketData,[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],MarketDataType.Last,-[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],DateTime.Now);
            OnMarketData([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],e);[/SIZE][/FONT][/SIZE][/FONT]
            and inside OnMarketData I do this:

            if e.Price>=0 //do what I have to do for MarketDataEvent
            else //call from my code

            Will that work or I´ll have any problem?

            Comment


              #7
              No, that is not supported.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Hello,

                This may or may not work and is unfortunately not supported. You would have to test this on your end to see what is possible.

                Let me know if I can be of further assistance.
                BrettNinjaTrader Product Management

                Comment


                  #9
                  I proved it and so far it seems to work

                  If I have any problem I'll let you know

                  thanks

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  601 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  347 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  103 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  559 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  558 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X