Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

using named parameters and defaults when using an indicator in a strategy or column

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

    using named parameters and defaults when using an indicator in a strategy or column

    Hi,

    When I use an indicator that I made in a strategy or custom column, i have to fill out all the default parameter settings when i reference the indicator. It seems that it wont just take the defaults that are defined in my custom indicator.

    So my custom indicator has a couple dozen settings. So its rather daunting in that if I dont set the parameters in perfect sequence i wiil get problems. the problem gets worse if i update my settings in my indicator, and I have to literally read through the list to make sure all the new settings are in order for the custom column or strategy that uses that indicator.

    Therefore, I am hoping for 3 possible ways to help manage this..

    1) is there someway where the indicator can just utilize the default settings that are defined in the indicator?

    2) Can I use named parameters like this (i know we dont use new in the strategy when referencing an indicator, but below is an example):

    Code:
    var customer = new Customer() {RequestID=request.ID, AddressID = 5 };
    3) We put defaults in the c# accessors, but it doesnt seem to work in ninjascript... Below is an example..
    Code:
    public int X { get; set; } = 5;

    #2
    Hello KhaosTrader,

    Thank you for your post.

    You can set the indicator as a type and then call that variable in your code. An example is present in the SampleMACrossOver when calling the SMA. Refer to the attached image.

    Please let me know if you have any questions.
    Attached Files

    Comment


      #3
      Hi, my custom indicator has over 100 parameters. I know how to pass variables to the type. I worry about getting out of sequence, so I was hoping to do named paramaters to variables... So that I can make sure the right value is being placed in the right order

      Comment


        #4
        Originally posted by KhaosTrader View Post
        Hi,

        When I use an indicator that I made in a strategy or custom column, i have to fill out all the default parameter settings when i reference the indicator. It seems that it wont just take the defaults that are defined in my custom indicator.

        So my custom indicator has a couple dozen settings. So its rather daunting in that if I dont set the parameters in perfect sequence i wiil get problems. the problem gets worse if i update my settings in my indicator, and I have to literally read through the list to make sure all the new settings are in order for the custom column or strategy that uses that indicator.

        Therefore, I am hoping for 3 possible ways to help manage this..

        1) is there someway where the indicator can just utilize the default settings that are defined in the indicator?
        Not really, because of the way that NT sets up indicators using a SetUp() internal method.
        2) Can I use named parameters like this (i know we dont use new in the strategy when referencing an indicator, but below is an example):

        Code:
        var customer = new Customer() {RequestID=request.ID, AddressID = 5 };
        Yes.
        3) We put defaults in the c# accessors, but it doesnt seem to work in ninjascript... Below is an example..
        Code:
        public int X { get; set; } = 5;
        I am not sure that I quite understand what you are saying here.

        Comment


          #5
          hi, koganam...

          on point 2, it doesnt work because we dont use the "new" keyword, so I cant seem to get the named parameters.

          point 3, is a way to set default values on accessors that was brought in with c# ver 6 i think, but it wont work for ninjascripts somehow.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Segwin, 05-07-2018, 02:15 PM
          14 responses
          1,789 views
          0 likes
          Last Post aligator  
          Started by Jimmyk, 01-26-2018, 05:19 AM
          6 responses
          837 views
          0 likes
          Last Post emuns
          by emuns
           
          Started by jxs_xrj, 01-12-2020, 09:49 AM
          6 responses
          3,294 views
          1 like
          Last Post jgualdronc  
          Started by Touch-Ups, Today, 10:36 AM
          0 responses
          13 views
          0 likes
          Last Post Touch-Ups  
          Started by geddyisodin, 04-25-2024, 05:20 AM
          11 responses
          63 views
          0 likes
          Last Post halgo_boulder  
          Working...
          X