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

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.

    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.

        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.

                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 bortz, 11-06-2023, 08:04 AM
                  47 responses
                  1,606 views
                  0 likes
                  Last Post aligator  
                  Started by jaybedreamin, Today, 05:56 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post jaybedreamin  
                  Started by DJ888, 04-16-2024, 06:09 PM
                  6 responses
                  18 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by Jon17, Today, 04:33 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post Jon17
                  by Jon17
                   
                  Started by Javierw.ok, Today, 04:12 PM
                  0 responses
                  13 views
                  0 likes
                  Last Post Javierw.ok  
                  Working...
                  X