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

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)
    {
     
     }

    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

      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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rdtdale, Today, 01:02 PM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by alifarahani, Today, 09:40 AM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by RookieTrader, Today, 09:37 AM
            4 responses
            18 views
            0 likes
            Last Post RookieTrader  
            Started by PaulMohn, Today, 12:36 PM
            0 responses
            9 views
            0 likes
            Last Post PaulMohn  
            Started by love2code2trade, 04-17-2024, 01:45 PM
            4 responses
            41 views
            0 likes
            Last Post love2code2trade  
            Working...
            X