Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator with dynamically changing Parameters

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

    Indicator with dynamically changing Parameters

    Hello,

    I am just making my first steps with indicator development with NinjaScript and just came across my first sticking point.

    I created an indicator which:
    1. Has 2 Input Parameters (ValueA and ValueB)
    2. Returns the Sum of these 2 Parameters
    This seems to work fine if I just use it on a regular Chart.

    But I want to use this indicator in a strategy, where:
    1. I want to use it to set the value of a Variable
    2. the 2 Input Parameters (ValueA and ValueB) are set by two strategy-variables which are also changing
    This does not work. I guess I need to update the Inputs on every barupdate or something similar? I dont know.
    Thanks in advance for any answers and pointers. I have attached the indiactor.


    Attached Files

    #2
    Hello zigzagzag,

    Thanks for your post.

    The indicator you posted will only do that math on the two inputs that are set when you apply the indicator.

    It would likely be easier for you to incorporate the indicator calculations inside the strategy code if possible.

    You can set the values for user inputs however these are basically read-only meaning you would not be able to change them through the script. You can assigned the user input values to internal variables that can be changed.

    I'm not entirely certain of what you are wanting to accomplish, however if you want to expose indicator values, that are not plots, please see this educational example: https://ninjatrader.com/support/help...alues_that.htm

    Comment


      #3
      Hi PualH,

      Thank you for your answer, I basically created these two Variables in the StrategyBuilder:

      Click image for larger version  Name:	var.png Views:	0 Size:	21.1 KB ID:	1119116

      Every Trade, they get populated with the latest Entry and Stopp Price. On each new entry, I want my indicator to do the calculation, so that I can then popluate another Variable with the result.

      I am not sure if I even need to expose the indicator value.
      Also I would like to create the strategy with the strategy builder and use this indicator as a building block, which means I do not want to incorporate the indicator calculations inside the strategy code.
      Last edited by zigzagzag; 09-21-2020, 08:21 AM.

      Comment


        #4
        I think I am now able to describe it even better:
        1. In the strategy builder I use the "Conditions and Actions" to set a variable (V1)
        2. I try to use this variable (V1) as a Parameter-input in the indicator
        The problem I come across is, that the indicator does not recognize the input. It just always prints 0 in the NinjaScript Output when I backtest it. If I use the indicator in a chart, it just prints out the parameter as expected (which in this case I input manually)
        Last edited by zigzagzag; 09-21-2020, 11:29 AM.

        Comment


          #5
          Hello zigzagzag,

          Thanks for your reply.

          The issue is those indicator parameters are only set once in State.DataLoaded when the indicator is used in a strategy and the variables have no values at that point (other than the default ones).

          If you could elaborate on what your overall intent or objective is we may be able to offer a solution. Otherwise I can continue to answer specific questions.

          Comment


            #6
            Hi PaulH,

            thank you for your help, I decided to jsut do these claculations in the StrategyCode after all.

            Comment

            Latest Posts

            Collapse

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