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 rocketman7, Today, 01:00 AM
        0 responses
        1 view
        0 likes
        Last Post rocketman7  
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        27 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 04-23-2024, 09:53 PM
        2 responses
        74 views
        0 likes
        Last Post wzgy0920  
        Started by Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        193 views
        0 likes
        Last Post Hasadafa  
        Working...
        X