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

NT 8 crashes after start up

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

    NT 8 crashes after start up

    Hi there,

    I'm facing an annoying problem concerning the start up of NT8.
    After starting the application, I see the following exception with in immediate shutdown without having the chance to react.

    Click image for larger version

Name:	05-08-_2021_11-04-18.png
Views:	201
Size:	5.2 KB
ID:	1166537


    I added my own implementation of an indicator which is using the system clipboard to store some price data. The following function does the job:

    private void setClipboard()
    {
    try{
    int multiply = BarsPeriod.BarsPeriodType == BarsPeriodType.Day ? 24 * 60 * 60 : 1;
    int timeframeMin = multiply * BarsPeriod.Value;
    string text = "" + timeframeMin + "; " + sequenzen.Last().sigHochTiefList.Last().high + "; " + sequenzen.Last().sigHochTiefList.Last().low + "; "
    + ATR(Close, 14)[1];
    Thread thread = new Thread(() => Clipboard.SetText(text));
    thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
    thread.Start();
    thread.Join();
    } catch (Exception ex) {
    Print(ex.Message.ToString()+"\\n" + ex.StackTrace.ToString());
    }
    }


    I'm a Java guy without experience in the C# universe. To me, catching an exception should not cause an app to crash. Obviously in the C# world things are a little different.

    My questions are:
    1. How do I (unharmfully) recover NT to perform a normal startup?
    - to me it seems, that all the script compiling is resulting in the "NinjaTrader.Custom.dll" file - is that correct?
    - my naive thoughts are that deleting this file might NT force to do a complete recompile - didn't try so far
    2. How can I modify my code to use the system clipboard in an safe way?
    - just looking at the code in this second, maybe I have to place the try - catch around the Lamba expression ;-) could make sense...

    Thanks in advance,
    Martin

    #2
    Ok, got it on my own...
    • removing NinjaTrader.Custom.dll seems to work, when my script is removed - the dll is created at start up
    • putting the try catch in the lambda was also an good idea

    An further question remains: putting an .cs file in the indicator directory is not sufficient to make it selectable in the UI - had to import it via an appropriate zip archive.
    Is there an configuration file that holds the selectable indicator? Or is there a more advanced registration process for custom indicators/strategies?

    Thanks,
    Martin

    Comment


      #3
      Hello Holladi,

      Thank you for your posts.

      Glad you were able to debug successfully.

      If a custom indicator or strategy requires referencing another script and that script isn't installed on that particular installation already before you try to just manually put the first script in the indicators folder, it wouldn't compile and thus wouldn't show up in the indicator list. Exported scripts will include any referenced scripts along with them in the .Zip file, so that may be why just putting the script in the indicators folder wouldn't work for you but importing a .Zip file did.

      Please let us know if we may be of further assistance to you.
      Kate W.NinjaTrader Customer Service

      Comment


        #4
        Hi Kate,

        thanks for your explanation. Although I don't quite understand

        Given custom strategy file A.cs uses custom indicator B.cs. File A.cs is in the Strategies folder (by copying not importing). File B.cs is missing in the Indicators folder. You say that A will not show up in the Strategies, because the dependent file B.cs is missing. Is this what you want to say?
        If so, a custom indicator not referring to any other custom indicator should show up in the indicators list by just copying the cs-file to the Indicators directory?

        Please allow me to put another question into this post:
        Do you have an code example for using the OnRender function within NT? I'm considering -simply put- to get some price information into the Windows clipboard depending on where your mouse postion is (i.e. by doing a double click on that location and identifying the bar that is at/under the mouse pointer).

        Thank you,
        Martin


        Comment


          #5
          Hello Holladi,

          Thank you for your reply.

          You're essentially correct - basically, if there's something in the manually imported script that causes a compile error, for example, a file that it needs to reference, then it won't show up in the indicator list until whatever's causing it to not compile is fixed. In the case you mentioned above, most likely it's a missing reference file that was included in the exported .Zip.

          There's a built in Sample Custom Render indicator that I'd advise taking a look at for a number of tips regarding using SharpDX rendering in OnRender that may be helpful to you, but that doesn't quite sound like what you're looking for. I'd also recommend taking a look at the scripts my colleague Chelsea created on this forum post that demonstrate getting the price/time associated with clicking on the chart at a specific point or rendering objects based on a mouse click:



          Please let us know if we may be of further assistance to you.
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            Thank you for your great support, Kate!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by DanielSanMartin, Yesterday, 02:37 PM
            2 responses
            12 views
            0 likes
            Last Post DanielSanMartin  
            Started by DJ888, 04-16-2024, 06:09 PM
            4 responses
            12 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by terofs, Today, 04:18 PM
            0 responses
            11 views
            0 likes
            Last Post terofs
            by terofs
             
            Started by nandhumca, Today, 03:41 PM
            0 responses
            7 views
            0 likes
            Last Post nandhumca  
            Started by The_Sec, Today, 03:37 PM
            0 responses
            3 views
            0 likes
            Last Post The_Sec
            by The_Sec
             
            Working...
            X