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 judysamnt7, 03-13-2023, 09:11 AM
          4 responses
          59 views
          0 likes
          Last Post DynamicTest  
          Started by ScottWalsh, Today, 06:52 PM
          4 responses
          36 views
          0 likes
          Last Post ScottWalsh  
          Started by olisav57, Today, 07:39 PM
          0 responses
          7 views
          0 likes
          Last Post olisav57  
          Started by trilliantrader, Today, 03:01 PM
          2 responses
          21 views
          0 likes
          Last Post helpwanted  
          Started by cre8able, Today, 07:24 PM
          0 responses
          10 views
          0 likes
          Last Post cre8able  
          Working...
          X