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

Operator Error Message

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

    Operator Error Message

    I am writing an indicator that is a variation of the CCI. The CCI normally uses typical which is (high + low + close) / 3. I want to redefine typical to be
    myTypical = (Max(High, 3)+Min(Low, 3)+Close) / 3

    Simple enough but I don't know how to work around the strongly typed C#.

    These are the code snippets where I attempt to do this.
    Variable Declaration...
    private DataSeries myTypical;

    protected void RedefineTypical()
    {
    myTypical.Set((Math.Max(High[0], 3)+Math.Min(Low[0], 3)+Close[0]) / 3);
    }
    Ok I know you know what's coming next. I get a compile error stating Operator '+' cannot be applied to operands of type 'NinjaTrader.Data.lDataSeries' and 'NinjaTrader.Data.lDataSeries'

    Also I get an error "the best overloaded method match for system.math.mas(sbyte,sbyte) has some invalid arguments. argument '1' cannot convert from ninjatrader.dat.idataseries to sbyte.
    Thank you for your help.
    Mike
    Last edited by Mike Winfrey; 08-03-2007, 06:00 PM.

    #2
    Code line below has no error. Just click on the error message, it will bring you to the erroneous code line.

    Comment


      #3
      Operator Error Message

      Thank you for the timely reply, especially at midnight. Holy cow...don't you sleep? Incredible. Anyway, I know about double clicking on the error message which is how I found out where the error is and the error is just as I described. However, I notice that I sent you the wrong code. That error was accurate for that code but obviously doesn't apply now. Don't know what I was thinking but anyway can we please start over.

      Here's the real code that I want to work...a screen shot of this code and the error are attached. The screen shot also shows how I want to use this method and is at the bottom of the code.

      #region Variables
      private int period = 14;
      private DataSeries myTypical;
      #endregion

      protected void RedefineTypical()
      {
      myTypical.Set((Math.Max(High, 3)+Math.Min(Low, 3)+Close) / 3);
      }

      protected override void OnBarUpdate()
      {
      if (CurrentBar == 0)
      Value.Set(0);
      else
      {
      double mean = 0;
      for (int idx = Math.Min(CurrentBar, Period - 1); idx >= 0; idx--)
      mean += Math.Abs(myTypical[idx] - SMA(myTypical, Period)[0]);
      Value.Set((myTypical[0] - SMA(myTypical, Period)[0]) / (mean == 0 ? 1 : (0.015 * (mean / Math.Min(Period, CurrentBar + 1)))));
      }
      }
      Attached Files

      Comment


        #4
        Here is one problem, you as passing in a DataSeries object of high prices (High) to Math.Max() instead of a double value.

        Math.Max(High[0], 3)

        instead of

        Math.Max(High, 3)
        RayNinjaTrader Customer Service

        Comment


          #5
          Thank you...i made the change as you suggested which looks like this.

          myTypical.Set((Math.Max(High[0], 3)+Math.Min(Low[0], 3)+Close[0]) / 3);

          and now it successfully compiles. I have other issues now but i'll work on them a bit before I bother anyone with it.

          Thanks,
          Mike

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by XXtrader, Today, 11:30 PM
          0 responses
          1 view
          0 likes
          Last Post XXtrader  
          Started by MarianApalaghiei, Today, 10:49 PM
          2 responses
          8 views
          0 likes
          Last Post MarianApalaghiei  
          Started by love2code2trade, Yesterday, 01:45 PM
          4 responses
          28 views
          0 likes
          Last Post love2code2trade  
          Started by funk10101, Today, 09:43 PM
          0 responses
          8 views
          0 likes
          Last Post funk10101  
          Started by pkefal, 04-11-2024, 07:39 AM
          11 responses
          37 views
          0 likes
          Last Post jeronymite  
          Working...
          X