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

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

    Paul H.NinjaTrader Customer Service

    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.
          Paul H.NinjaTrader Customer Service

          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 DawnTreader, 05-08-2024, 05:58 PM
            22 responses
            81 views
            0 likes
            Last Post DawnTreader  
            Started by Mathias79, Today, 03:44 PM
            0 responses
            17 views
            0 likes
            Last Post Mathias79  
            Started by Austiner87, Today, 03:42 PM
            0 responses
            11 views
            0 likes
            Last Post Austiner87  
            Started by lorem, 04-25-2024, 09:18 AM
            19 responses
            83 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by joselube001, 05-10-2024, 12:17 PM
            6 responses
            29 views
            0 likes
            Last Post joselube001  
            Working...
            X