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 to pass Primary DataSeries to Custom Method

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

  • NinjaTrader_ChelseaB
    replied
    Hello aventeren,

    The message you got is likely because you have your method set to accept a parameter.

    Try removing this.

    Leave a comment:


  • aventeren
    replied
    When I attempt to not pass a DataSeries to myMethod by doing this:

    Code:
    myMethod();
    I'm getting a No Overload for myMethod takes 0 arguments error.

    I then go back to trying to pass myMethod the Close DataSeries by doing this:

    Code:
    myMethod(Close);
    But then I get an error that says that I cannot convert from the 'NinjaTrader.Data.IDataSeries' to 'NinjaTrader.Data.DataSeries'. So it looks like Close is an IDataSeries type and the secondary series is defined as a DataSeries type. Is it possible to pass the primary DataSeries Close values as a NinjaTrader.Data.DataSeries type instead of as a .IDataSeries type?

    Leave a comment:


  • aventeren
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello aventeren,

    The custom method will use which ever data series you call.

    Have you given this a test?
    I'm hunting errors (this is one of many), so I am not able to test.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello aventeren,

    The custom method will use which ever data series you call.

    Have you given this a test?

    Leave a comment:


  • aventeren
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hi aventeren,

    You may not need to pass the series.

    Have you tried printing the close of the current bar in the custom method without passing the data series?

    For example:

    protected void myMethod()
    {
    Print(Close[0]);
    }
    So if you leave the DataSeries field blank in a custom Method NT knows to use the primary DataSeries?

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hi aventeren,

    You may not need to pass the series.

    Have you tried printing the close of the current bar in the custom method without passing the data series?

    For example:

    protected void myMethod()
    {
    Print(Close[0]);
    }

    Leave a comment:


  • aventeren
    started a topic How to pass Primary DataSeries to Custom Method

    How to pass Primary DataSeries to Custom Method

    Hello--

    I have created a secondary DataSeries (let's call it myDataSeries) and a custom Method that take a DataSeries as one of the parameters (let's call it myMethod(Dataseries targetDataSeries)).

    Some times I want to pass myDataSeries into myMethod by doing this:

    Code:
    myMethod(myDataSeries);
    However, sometimes I just want to pass the primary DataSeries to myMethod. I have attempted to do this with the following code, but I am getting an error:

    Code:
    myMethod(Close);
    What is the proper way to pass the primary DataSeries Close values to a custom Method?

    Thanks,

    Aventeren

Latest Posts

Collapse

Topics Statistics Last Post
Started by trilliantrader, 04-18-2024, 08:16 AM
5 responses
22 views
0 likes
Last Post trilliantrader  
Started by Davidtowleii, Today, 12:15 AM
0 responses
3 views
0 likes
Last Post Davidtowleii  
Started by guillembm, Yesterday, 11:25 AM
2 responses
9 views
0 likes
Last Post guillembm  
Started by junkone, 04-21-2024, 07:17 AM
9 responses
68 views
0 likes
Last Post jeronymite  
Started by mgco4you, Yesterday, 09:46 PM
1 response
12 views
0 likes
Last Post NinjaTrader_Manfred  
Working...
X