Announcement

Collapse
No announcement yet.

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, 05:00 PM.

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

    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 Leeroy_Jenkins, Today, 03:00 AM
          0 responses
          1 view
          0 likes
          Last Post Leeroy_Jenkins  
          Started by Prasanna, Today, 02:53 AM
          0 responses
          1 view
          0 likes
          Last Post Prasanna  
          Started by PeterInBrisbane, Today, 01:07 AM
          0 responses
          9 views
          0 likes
          Last Post PeterInBrisbane  
          Started by fdalgoi, Today, 12:44 AM
          0 responses
          6 views
          0 likes
          Last Post fdalgoi
          by fdalgoi
           
          Started by thomaswilleford, Today, 12:07 AM
          0 responses
          3 views
          0 likes
          Last Post thomaswilleford  
          Working...
          X