Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Creating Sender/Receiver messaging within within Ninja 8 ??

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

    Creating Sender/Receiver messaging within within Ninja 8 ??

    Hello,

    Please if you have suggestions on how to implement this better, or can tell me how to add "listener" capabilities to my Strategy, please tell me here.

    For Ninja 8, I have written generic Trade Server" that runs as a Strategy in Strategy Analyzer. It places orders and then manages positions similar to the Ninja ATM.

    I want this trade server to listen for trade signals from one or more Indicators (Trade Trigger)...I do not want to couple an indicator to the Trade Server, but have the Trade Server be able to listen for signals from one or more Trade Trigger Indicators at the same time.

    (Once an order has been received, the Trade Server would not act on another incoming order, until the order / trade was completed.)

    So, in Strategy Analyzer there would be one Trade Server executing for one instrument. Each Trade Server (for a specific instrument, such as FDAX, CL, ES, UB) ) would be listening for signals from one or more Trade Trigger indicators (for the same instrument).

    So, there needs to be a way that when a specific Trade Server starts up for it to publish a handle so that when a corresponding Trade Trigger (Indicator) starts up, it can find the Trade Server and send messages to it.

    I've been able to do a lot in Ninjascript C#, but this is beyond my current skill set.

    In other work I've implemented XMPP iand MSMQ interfaces into my code....as senders, but not as listeners

    Because of the thread locking when listening and receiving MSMQ (or I suppose Named Pipes also) messages have found that it did not mix well in a Ninja process, which needs to not be locked for any reason.

    (I have MSMQ listeners working well outside of Ninja, for other processes, such as logging, external published alerts, etc)

    Is there a way for a running strategy to publish an external interface to one of its internal methods (i.e. a listener/receiver method), so that an external process can pass information to it and trigger it?

    Or, do you have other ideas that you have proven works?

    Many thanks

    #2
    Originally posted by vantojo View Post
    Because of the thread locking when listening and receiving MSMQ (or I suppose Named Pipes also) messages have found that it did not mix well in a Ninja process, which needs to not be locked for any reason.

    (I have MSMQ listeners working well outside of Ninja, for other processes, such as logging, external published alerts, etc)
    Did you try putting the listener inside its own separate thread?

    Comment


      #3
      I could probably try the C# backgroundworker class to do that...but am cautious about launching asynchonous threads in Ninja. I've used it successfully in native C# programs to insulate the main process from a receiver method that lock the thread it is in.

      I don't know much about C# delegates, but that might work also

      I can spend a lot of time tracking this down....perhaps someone here in this Forum has done something similar?

      Comment


        #4
        Hi vantojo, thanks for your post.

        We do offer a DLL interface where you can write a .NET application external to NinjaTrader and interact with NinjaTrader through this DLL. These types of projects are unsupported, but we have a framework example here:

        https://ninjatrader.com/support/foru...layed-in-chart

        Any server or some external program would be out of the scope of support I can provide. I wanted to confirm that you know that indicator objects can be instantiated in a strategy, take the SampleMACrossover for example, it creates two SMA objects and uses them to make trading decisions.

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hi Chris,

          Thank you.

          I want to avoid instantiating Indicators to the Strategy...the Trade Server needs to take input from multiple indicators ... the first signal is acted on for the duration of the trade...others would be discarded.

          Are there any frameworks available for something like this?

          What I need is to get a way to get the Trade Signal from the Indicator to the Trade Server without tight coupling (i.e. instantiating one indicator to the Strategy).


          Thanks

          Comment


            #6
            NT7 @Pivots.cs used a worker thread to call Data.Bars.GetBars ...

            Comment


              #7
              thanks, will look at that... @Pivots

              Comment


                #8
                Hi vantojo, thanks for your reply.

                There are no supported ways of doing anything like this, unfortunately.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Regarding the question from vantojo : Is NT8 Addon running in separate thread ? If yes , it seems message receiver/sender logic could be implemented in an addon , without blocking anything. Would it be possible ?
                  Thanks,

                  Comment


                    #10
                    Hello xTrader1, thanks for your question.

                    Addons do run in their own thread. Any custom threading/dispatchers are more of a C# issue and go beyond the scope of support I could provide. I made this addon in the past that implements a property changed event that multiple scripts can subscribe to in order to get global property changed events:

                    https://ninjatrader.com/support/foru...dsaddonexample

                    Please let me know if I can assist any further.
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      Addons do run in their own thread? OR Every addon runs in its own thread ? Important. Thanks.

                      Comment


                        #12
                        Hello, thanks for your reply.

                        Each instance of the Addon will run in its own thread, see the AddonFramework example's OnMenuItemClick event:

                        private void OnMenuItemClick(object sender, RoutedEventArgs e)
                        {
                        Core.Globals.RandomDispatcher.BeginInvoke(new Action(() => new AddOnFrameworkWindow().Show()));
                        }

                        Please let me know if I can assist any further.
                        Chris L.NinjaTrader Customer Service

                        Comment


                          #13
                          Thank you ,

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Renejm, Today, 06:17 AM
                          0 responses
                          3 views
                          0 likes
                          Last Post Renejm
                          by Renejm
                           
                          Started by kazisl, Yesterday, 06:41 PM
                          2 responses
                          9 views
                          0 likes
                          Last Post NinjaTrader_PaulH  
                          Started by impactX, 05-04-2021, 01:07 AM
                          1 response
                          7 views
                          0 likes
                          Last Post Lancer
                          by Lancer
                           
                          Started by op1031, Yesterday, 05:51 PM
                          1 response
                          8 views
                          0 likes
                          Last Post NinjaTrader_PaulH  
                          Started by aaadetos, 05-04-2021, 09:28 AM
                          2 responses
                          10 views
                          0 likes
                          Last Post aaadetos  
                          Working...
                          X