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

Too many characters

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

    Too many characters

    I am having a hard time making even simple indicators.

    I keep getting an error on Line 44, which by default from NT is a comment line! It says CS1012 Too many characters in character literal.?

    The only thing I did to the code is change within the () on lines 45 and lines 46. I created 2 lines so there are 2 things to code.


    /// <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, "Top"));
    Add(new Plot(Color.FromKnownColor(KnownColor.DarkOrange), PlotStyle.Line, "Bottom"));
    Overlay = true;
    }

    /// <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
    44
    Top.Set(High[0]);
    Bottom.Set(Low[0]);
    }


    [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 Bottom
    {
    get { return Values[1]; }
    }

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

    #2
    illcrx, where's the 44 there coming from? Was this added by you to show the line here for the post? As presented I would not expect it to compile.

    If you can add the full cs here, we could give it a run and let you know what we see offending.

    Thanks,
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Ok there you go....thanks
      Attached Files

      Comment


        #4
        Thanks, but this compiles just fine here - are you sure the compile errors are found in this very script you referenced? Please keep in mind in NT all scripts would be always compiled, so the error could be in another script as well, if you double click on the error message it would directly take you to the offending code / cs.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          try this one

          I just made this one to just show average volume, Im not even sure the code is correct but its still states Too many characters in character literal on line44 WHICH HAS A CURLY BRACE ON IT!

          If you complile correctly then there is something wrong with my ninja trader, if thats the case should I uninstall and re-install?

          Keep in mind this is yet another program where it has an error on line 44 column 23. Its the same place on every code I attempt to write.

          I just wrote this a minute ago and its the right one.

          Thanks again.
          Attached Files

          Comment


            #6
            illcrx,

            The error I get is:

            Indicator\AvgVol.cs The name 'AverageVolume' does not exist in the current context CS0103 - click for info 43 23

            I don't see AverageVolume defined anywhere so that would make sense here. You've been looking at this for a couple days so please feel free to send a note to support 'at' ninjatrader 'dot' com so we can further assist via remote.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              I just tried compiling a preloaded script and I got the same error! Im going to uninstall and re-install it. I'll let you know how it goes.

              Error line 44 column 23

              Comment


                #8
                OK, it may not fix it unless you also manually delete the Documents\NinjaTrader 7 folder after uninstalling from control panel. If you don't want to lose any custom work, send us an email note and include a link to this thread. It might not hurt to have another set of eyes on it.

                Based on your posts it sounds like the error is in a different file than you're editing at the time.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  I just tried uninstalling and reinstalling that didnt work. So now your saying I should delete all files, because it didnt delete the indicators and it didnt change anything so I'll do that!

                  Comment


                    #10
                    Ok cool that worked I can finally do something!

                    Comment


                      #11
                      For learning I would get started with the indicator tutorials first. They help introduce to the general structure of indicators.


                      There's always more than one way to do something. Here's one way of setting plot to 20 bar average volume:

                      Plot0.Set(SMA(Volume, 20)[0]);
                      Ryan M.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by techgetgame, Yesterday, 11:42 PM
                      0 responses
                      8 views
                      0 likes
                      Last Post techgetgame  
                      Started by sephichapdson, Yesterday, 11:36 PM
                      0 responses
                      2 views
                      0 likes
                      Last Post sephichapdson  
                      Started by bortz, 11-06-2023, 08:04 AM
                      47 responses
                      1,615 views
                      0 likes
                      Last Post aligator  
                      Started by jaybedreamin, Yesterday, 05:56 PM
                      0 responses
                      10 views
                      0 likes
                      Last Post jaybedreamin  
                      Started by DJ888, 04-16-2024, 06:09 PM
                      6 responses
                      20 views
                      0 likes
                      Last Post DJ888
                      by DJ888
                       
                      Working...
                      X