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

Changing indicator parameter values dynamically, updating strategy

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

    Changing indicator parameter values dynamically, updating strategy

    I am calling an indicator in the namespace from a strategy, just like the 'Alan.." code examples, and send parameter values from the strategy to the indicator in the call statement within the following booleans for orders:

    Code:
    buyStop = CrossAbove( myRSI(param1,param2,param3,param4).rsi, myRSI(param1,param2,param3,param4).rsilower, 1); 
    shortStop = CrossBelow( myRSI(param1,param2,param3,param4).rsi, myRSI(param1,param2,param3,param4).rsiupper,1);
    On occasion an unknown combination of parameter values will cause the rsi>100, and know that (inside the indicator) if I pad (add a 1) to param1 the overflow will be prevented. So at the end of OBU, if I trap out the error with some logical like

    Code:
    if rsi[0]>100)
    {
      param1 += 1;
      goto recalculatebar;
    }
    and use


    Code:
    OnBarUpdate
    {
       recalculatebar:
    ..
    I can recalculate rsi for the current bar and prevent the error from occurring. However, I need to dynamically:

    1. Ensure the indicator passes the reset param1 value back to the strategy
    2. Ensure the Strategy Optimizer never saw the bad parameter value
    3. Make sure the indicator display will show the reset param1 value, since for a given chart the new param1 value is used over all bars.

    Thus, I need to dynamically reset a param value inside an indicator's OBU and have everything recognize the param value was changed, and not have the strategy optimizer ever see the "bad" param value for the current iteration during the genetic optimizer training.
    Last edited by pel11; 06-25-2018, 09:15 AM.

    #2
    Hello pel11,

    I'm not seeing any custom namespaces in the code you have provided.

    What is the error message you are getting?

    What is myRSI? Is this the RSI indicator or a custom indicator you have written?

    The RSI included with NinjaTrader has two parameters, the Period and the Smooth.

    When using the RSI plot, this does need to be upper case.

    For example:

    private RSI = myRSI(14, 3);

    CrossAbove( myRSI.RSI, 30, 1);

    This would trigger if the RSI plot crosses above 30 (the lower line).


    I'm not understanding what you are trying to do with the goto.

    If you are trying to re-calculate the historical data, you would need to do this with a loop that loops through from 0 to the CurrentBar and reset the values..
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      myRSI is a custom indicator, and I said I was calling the namespace of an indicator,so dont think about RSI(,) in NT8. You also need to read the OP, since specifically states why there is a go to that recalculated the bar[0] values. Please read the OP and also look at Alan's code example (he's in support at NT)

      Comment


        #4
        Hello pel11,

        Which code example are you referring to where (I'm assuming you are referring to NinjaTrader_AlanP) Alan has used goto?

        Also, I can see that you are using a goto to a spot recalculatebar in your first post, but there is no further information about what you are trying to do with this and no code is included on what is run after this.

        Is this unneeded information that is not involved with your inquiry?

        If you are trying to recalculate historical bars, is a loop from the most recent bar to first bar to set new values not sufficient to achieve your goals?
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        22 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        45 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        21 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X