• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.

          http://ninjatrader.com/support/forum...d.php?p=489504

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GLFX005, Today, 12:22 PM
          2 responses
          35 views
          0 likes
          Last Post NinjaTrader_Kate  
          Started by AspenHiker, Today, 08:37 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Kate  
          Started by MartinT, Yesterday, 01:12 PM
          3 responses
          15 views
          0 likes
          Last Post MartinT
          by MartinT
           
          Started by caveat_lector, Today, 11:58 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Heath  
          Started by Bionian, Today, 11:43 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Kate  
          Working...
          X