Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I pass in CCI(14) to a method

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

    How do I pass in CCI(14) to a method

    Hi, I want to write a method that will take an indicator parameter and then check swings on it. I want to pass various indicators to this function... I don't know how to do that.

    Here is what I want to do from an indicator or strategy:

    CCI(14) is the indicator I want to pass to the method

    then call

    MFSwing (CCI(14))
    or
    MFSwing (ROC(14))

    publicbool MFSwing ("somehow pass in CCI(14)")
    {
    bool retval = false;
    // Swing
    if (Swing("somehow use CCI(14) here ",1).SwingLowBar(1, 1, 4))
    {
    retval=true;

    }


    return (retval);
    }

    I don't know how or if I can do that.

    #2
    Hello,

    Thanks for the note.

    You would use this syntax:

    Code:
    private void Method(IDataSeries dataSeries)
    {
     
     }
    BrettNinjaTrader Product Management

    Comment


      #3
      Hello,

      Just to make sure I had to make an edit to the below post.

      Please recheck the below if you have already read my post.

      -Brett
      BrettNinjaTrader Product Management

      Comment


        #4
        Originally posted by NinjaTrader_Brett View Post
        Hello,

        Thanks for the note.

        You would use this syntax:

        Code:
        private void Method(IDataSeries dataSeries)
        {
         
         }
        Hi Brett, thanks for responding so quickly. I am not sure if I understand. I don't want to pass in the VALUE of the CCI(14), I want to pass in to the method to USE the indicator CCI(14) in that method.

        MFSwing (CCI(14)) - not the value, but tell the method to start using the indicator passed in.
        or

        MFSwing (ROC(14))

        publicbool MFSwing ("passed in indicator and parameter - IE: CCI(14)")
        {

        private int indicatorvalue;
        indicatorvalue = "passed in indicator and parameter - IE: CCI(14)"

        I want this to look like:
        indicatorvalue = CCI(14);
        or
        indicatorvalue = ROC(14);

        this is so I can reuse all the code for doing some custom swing stuff and keep it all together in 1 method and just pass in different indicators

        }


        Comment


          #5
          We are on the same page as you. I think the following code example will better illustrate the concept.

          Code:
          [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT]
          [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
          [SIZE=2][FONT=Courier New]   DoSomething(CCI([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]14[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]));[/SIZE][/FONT]
          [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
           
          [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] DoSomething(IDataSeries dataSeries)[/SIZE][/FONT]
          [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
          [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]   double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] indicatorValue = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
          [SIZE=2][FONT=Courier New]   indicatorValue = dataSeries[[/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]];[/SIZE][/FONT]
          [SIZE=2][FONT=Courier New]   Print(indicatorValue);[/FONT][/SIZE]
          [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
          [/SIZE][/FONT]
          RayNinjaTrader Customer Service

          Comment


            #6
            Hello,

            Please see this information as well on this to further round out your understanding and let me know if you have further questions.



            -Brett
            BrettNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            562 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            325 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            547 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X