Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

my first script

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

    my first script

    I seem to be missing something here.
    I can't get NinjaScript to work at all.
    I'm just trying to get it to print Hi at the output window and
    ever time I add anything to the bottom of what is below
    I will get an error. If I figure this out tonight I will repost.
    Putting // with comments if just fine
    but anything else results in an error, usually Namespace
    Member Declaration Expected.




    Thanks to any replies. -Stephen

    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    #endregion

    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class MyCustomIndicator : Indicator
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 1; // Default setting for MyInput0
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    CalculateOnBarClose = true;
    Overlay = false;
    PriceTypeSupported = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    Plot0.Set(Close[0]);
    }

    #region Properties
    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries Plot0
    {
    get { return Values[0]; }
    }

    [Description("")]
    [Category("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }
    #endregion
    }
    }

    #2
    Try deleting this script and start again.

    Close it, then select Tools > Edit NinjaScript > Indicator > selec this and press Delete button.
    RayNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Ray View Post
      Try deleting this script and start again.

      Close it, then select Tools > Edit NinjaScript > Indicator > selec this and press Delete button.
      Clearing the screen doesn't help.

      This is the program I wish to use:

      //Either/Or decision
      int x=1;
      if (x==0)
      {
      Print("Hi");
      }
      else
      {
      Print("Buy");
      }

      >>>>>>>>>>>>> Sorry..

      Might be on the wrong screen, but I don't think you want me to delete all
      the NinjaTrader indicators??
      Last edited by stephenszpak; 05-24-2008, 05:38 PM.

      Comment


        #4
        I wanted you to delete the indicator causing the issue and start from scratch.

        Here is a reference for debugging compile errors.

        RayNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Ray View Post
          I wanted you to delete the indicator causing the issue and start from scratch.

          Here is a reference for debugging compile errors.

          http://www.ninjatrader-support.com/v...ead.php?t=4678
          Ray

          Thanks, there is no indicator to my knowledge.
          I'm just trying to get some of the simple programs at "Getting Started with NinjaScript-
          Basic Syntax" to run. The program below is just 10 lines of code. I think I must
          be putting it in the wrong screen or something. Sorry this is so confusing to us.

          Is it possible for you to post an image of what I should be seeing on my computer
          and also where to add my short program within the image?

          -Stephen
          Last edited by stephenszpak; 05-24-2008, 08:59 PM.

          Comment


            #6
            Stephen,

            What you should be seing is "no errors".

            - Shut down NT
            - Restart
            - Tools > Edit NinjaScript > Indicator
            - Select "any" indicator, press F5
            ---> Does it compile?

            - NO, then delete the problem files as per my earlier messages/links
            - YES, great then there is no problem
            RayNinjaTrader Customer Service

            Comment


              #7
              I hope I uploaded an attachment showing what happened.
              I tried 3 indicators. I keep getting CS0116. These are 3 indicators
              that came with NT. I have not modified them.
              Attached Files

              Comment


                #8
                You will see that there is an error in the file "MyCustomIndicator". Please delete this indicator or fix the errors in this indicator. Please review this thread for past information and resource links that I have provided that can help you out.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Ray View Post
                  You will see that there is an error in the file "MyCustomIndicator". Please delete this indicator or fix the errors in this indicator. Please review this thread for past information and resource links that I have provided that can help you out.
                  I deleted this indicator, which had no other lines of code besides what
                  is seen below:

                  //Either/Or decision
                  int x=1;
                  if (x==0)
                  {
                  Print("Hi");
                  }
                  else
                  {
                  Print("Buy");
                  }

                  Now I no longer get an error when I press F5 on another indicator.
                  (Why one bad indicator messes up all the others is quite the mystery.)

                  I am now back to pretty much where I was.
                  I have no idea where to place my short program above. Maybe over time
                  I'll figure it out.

                  Thanks for trying, I usually have problems with things that require programming.


                  -Stephen

                  Comment


                    #10
                    Ok I figured it out. This is from the NT site:
                    ----------------------------------------------------------------------------------
                    Replace the wizard generated code with the following code into the OnBarUpdate() method in the NinjaScript Editor:
                    ----------------------------------------------------------------------------------

                    I used the above hint to show me where to put my program.

                    I added my code to this area and the program printed Buy to the NinjaTrader output
                    window when I ran it.
                    It printed BUY 20 times or so which I didn't think was supposed to happen.
                    Well, regardless, I'm a programmer now.

                    -Stephen

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Segwin, 05-07-2018, 02:15 PM
                    14 responses
                    1,789 views
                    0 likes
                    Last Post aligator  
                    Started by Jimmyk, 01-26-2018, 05:19 AM
                    6 responses
                    837 views
                    0 likes
                    Last Post emuns
                    by emuns
                     
                    Started by jxs_xrj, 01-12-2020, 09:49 AM
                    6 responses
                    3,293 views
                    1 like
                    Last Post jgualdronc  
                    Started by Touch-Ups, Today, 10:36 AM
                    0 responses
                    13 views
                    0 likes
                    Last Post Touch-Ups  
                    Started by geddyisodin, 04-25-2024, 05:20 AM
                    11 responses
                    63 views
                    0 likes
                    Last Post halgo_boulder  
                    Working...
                    X