Announcement

Collapse
No announcement yet.

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 asgegre, Today, 05:10 AM
        0 responses
        3 views
        0 likes
        Last Post asgegre
        by asgegre
         
        Started by asgegre, Today, 03:07 AM
        0 responses
        4 views
        0 likes
        Last Post asgegre
        by asgegre
         
        Started by MarkTee, Today, 02:53 AM
        0 responses
        5 views
        0 likes
        Last Post MarkTee
        by MarkTee
         
        Started by ldjaisohy, Today, 12:59 AM
        0 responses
        5 views
        0 likes
        Last Post ldjaisohy  
        Started by TheCatTrader, Yesterday, 04:52 PM
        1 response
        9 views
        0 likes
        Last Post s.kinra
        by s.kinra
         
        Working...
        X