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

Calling External Form from indicator

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

    Calling External Form from indicator

    I need some help before I run out of hair. This is probably beyond NT staff support so I would appreciate any programmer's help.

    I want to call a form so as not to disturb multi-time frame indicators which will become skewed on indicator refresh because of the way the access historical and real time data.

    I have tried to follow Folls' example, but can't seem to get beyond errors. I have attached the VisualStudio solution/project and NT NotesPanel.cs file.

    I created a NotesEditor.dll in VS which I placed in the Custom folder. The NotesPanel works well so long as reference to NotesEditor are commented out, so I have ruled out a problem there.

    I have added NotesEditor.dll as a reference in NT by right clicking the chart and going to references at the bottom.

    I added:

    using NinjaTrader.Indicator; //Not sure why this is needed
    using NotesEditor;
    using System.Windows.Forms;

    to the declarations

    The only difference in OnBarUpdate() is:
    if (firstTime) //defined as true in variables. show only once
    {
    editNotes.Show();
    firstTime = false;
    // if(editNotes.DialogResult == DialogResult.OK)
    {
    // note1 = editNotes.textBox1.Text;
    }
    }

    If I place:
    Editor editNotes = new Editor();//Editor is name of form to be called
    in variables as Folls did, I get errors galore and all my indicators blow up. So I guess this is not a good idea.

    If I place it in Initialize() I get an error stating:

    Failed to call method 'Initialize' for indicator 'NotesPanel': Could not load file or assembly 'NotesEditor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

    and then

    Failed to call method 'Initialize' for indicator '': Could not load file or assembly 'NotesEditor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

    I have shut down NT and restarted and recompiled to no avail. I am about out of ideas.

    Snap
    Last edited by snaphook; 09-03-2011, 12:56 PM.

    #2
    Figured it out.

    I am using Visual Studio 2010 and .Net 4 is the default. I switched to .Net 2 like Folls used and voila. Success, with a few tweaks. Now if some kind soul could walk me through adapting the code to a non-dll based format, I would appreciate it.

    Here is a simple little Notes (.dll based) Panel to allow you to keep up to 10 notes in a side panel. Using the Notes button in the Tool Strip opens a form where you can edit the notes to your hearts content and never call a refresh of the indicators. This is very helpful in multi-time frame charts.

    To install:
    without NinjaTrader running, extract NotesEditor.dll and NotesPanel.zip to the MyDocuments\NinjaTrader 7\bin\Custom folder.

    Start NinjaTrader and import the indicator from the .zip file. Go to Tools|Edit Ninjascript|Indicators and open NotesPanel. When it opens, Right Click in the window and select References at the very bottom, Add NotesEditor.dll, OK, and compile (F5).

    Now add the indicator to any chart. A new button should appear on the tool strip at the very right. Click the button to open the dialog and edit your notes.

    I see no reason this technique could not be adapted to any indicator.

    Indicator (NotesPanelFull.zip) and VS project files (NotesEditor.zip) are attached.

    Snap
    Attached Files
    Last edited by snaphook; 09-03-2011, 01:12 PM.

    Comment


      #3
      snaphook,

      Very cool! Glad to hear you figured it out and thanks for sharing.
      MatthewNinjaTrader Product Management

      Comment


        #4
        Non .dll based

        NinjaTrader is so cool. Here is a non .dll based version of Notes Panel with an external form call. Twenty minutes of research and 1 experiment and it compiled and runs beautifully.

        For Visual Studio users, here is what I did.

        1 I created a .Net 3.5 form, Editor, in Visual Studio, added an InputAlertHandler and told btnOK to call the IAH. VS built the code for the form, but under the namespace you named your project, NotesEditor on this one.

        2 I opened the NT indicator file and the two VS Form files (in this case Editor.cs and Editor.designer.cs) in a text editor, I use Notepad++.

        3. Then I copied everything from: public partial class Editor : Form, including that line, from Editor.cs and everything from: partial class Editor, from Editor.Designer.cs and just pasted them in front of OnBarUpdate. I suspect you could paste them anywhere you like as long as they were not within a method but within your Indicator class.

        4 Saved and compiled within NT. I guess NT created an internal class for the form.

        Voila. Très facile.

        I hope this helps someone.
        Attached Files
        Last edited by snaphook; 09-04-2011, 07:00 AM.

        Comment


          #5
          Originally posted by snaphook View Post
          NinjaTrader is so cool. Here is a non .dll based version of Notes Panel with an external form call. Twenty minutes of research and 1 experiment and it compiled and runs beautifully.



          Voila. Très facile.

          I hope this helps someone.
          Have you updated this for NT8?

          There is already a request.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Skifree, Today, 03:41 AM
          1 response
          3 views
          0 likes
          Last Post Skifree
          by Skifree
           
          Started by usazencort, Today, 01:16 AM
          0 responses
          1 view
          0 likes
          Last Post usazencort  
          Started by kaywai, 09-01-2023, 08:44 PM
          5 responses
          603 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by xiinteractive, 04-09-2024, 08:08 AM
          6 responses
          23 views
          0 likes
          Last Post xiinteractive  
          Started by Pattontje, Yesterday, 02:10 PM
          2 responses
          23 views
          0 likes
          Last Post Pattontje  
          Working...
          X