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

Remoting - Error.

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

    Remoting - Error.

    I'm attempting to implement .net's remoting in an indicator and I'm stuck at the very beginning.

    I've added the reference:

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.Runtime.Remoting.dll


    And my code:

    using System.Runtime.Remoting;
    using System.Runtime.Remoting.Channels;
    using System.Runtime.Remoting.Channels.Tcp;

    protected override void Initialize()
    {
    try
    {
    TcpChannel c = new TcpChannel(32469);
    }
    catch(Exception ex)
    {
    Print(ex.Message);
    }
    }

    When I open the Indicators Dialog, I get the following Error message printed in the Output window:
    "Only one usage of each socket address (protocol/network address/port) is normally permitted"

    I've tried a bunch of different port numbers so I'm pretty sure that is not the problem.

    Creating and registering (not show here) a channel is basically the first step in implementing a remoting server. I'm guessing this is clashing with something in NinjaTrader.

    Has anyone been able to get remoting working in an indicator? Any thoughts on how to proceed to troubleshoot/workaround this error?

    I'm trying to use remoting to workaround the NT6.5 limitation of not being able to utilize multiple data series from an indicator.

    thanks,
    shawnj

    #2
    Just to be safe, I would move the code to the OnBarUpdate() function and use an init variable

    if(!init)
    {
    init = true;
    //the rest of the code
    }

    I think sometimes the Initialize code is called multiple times prior to putting the indicator on the chart.
    mrlogik
    NinjaTrader Ecosystem Vendor - Purelogik Trading

    Comment


      #3
      Thanks mrlogik, I've implemented your logic and with some further trial and error I think I've concluded the following: When the Indicator is first applied and executed, the error does not occur, however, if I remove the Indicator and reapply it then reexecute it, the error returns. The only way I can get back to a clean execution is to exit NT and start over.

      This indicates to me that removing the Indicator is not releasing the TcpChannel object.

      So my next thought was to override the Indicator's Dispose to try to force the release of the TcpChannel object.

      public override void Dispose()
      {
      FTcpChannel.Dispose();
      base.Dispose();
      }

      Unfortunately the best I can tell, TcpChannel does not inplement Dispose() and I cant call Finalize(). This is getting into an area of C# that I'm pretty weak at.

      This attempt at implementing Remoting in a NT Indicator is "Eating my lunch <g>".

      Comment


        #4
        shawn,

        I think what you have should work. You don't see a Dispose() method for FTcpChannel?

        Either way, before you do it check to see if its null

        Code:
        if(FTcpChannel != null)
        {
        //dispose the FTcpChannel
        }
        some reading
        Last edited by mrlogik; 11-11-2008, 08:14 AM.
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,406 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        98 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        8 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        160 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        9 views
        0 likes
        Last Post Belfortbucks  
        Working...
        X