Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Change Indicator parameters based on condition

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

    Change Indicator parameters based on condition


    I am trying to change Indicator parameters based on condition (time). But I am unable to do so.
    I have tried putting the code in State.Configure , State.DataLoaded & OnBarUpdate()
    With on bar, the values don't match. With configure & data loaded, it errors out.
    Please advise & comment on the resource usage as well, if possible.

    if ((ToTime(Time[0]) >= 93000 && ToTime(Time[0]) < 110000))
    {
    currentVWAP = amaCurrentDayVWAP(Close, amaSessionTypeVWAPD.Custom_Hours, amaBandTypeVWAPD.Standard_Deviation, amaTimeZonesVWAPD.US_Eastern_Standard_Time, @"09:30", @"11:00", 1, 2, 3, 1, 2, 3);

    }
    else if ((ToTime(Time[0]) >= 110000 && ToTime(Time[0]) < 120000))
    {
    currentVWAP = amaCurrentDayVWAP(Close, amaSessionTypeVWAPD.Custom_Hours, amaBandTypeVWAPD.Standard_Deviation, amaTimeZonesVWAPD.US_Eastern_Standard_Time, @"11:00", @"12:15", 0.7, 1.25, 3, 0.7, 1.25, 3);
    }
    Print ("Current : " + currentVWAP.SessionVWAP[0]);


    Thanks in advance.



    #2
    Can someone from Ninja please comment on the above?
    Cheers!

    Comment


      #3
      Hello kashmiami,

      Welcome to the NinjaTrader forums!

      As a heads up, outside of our normal support hours the support has a minimal amount of representatives to provide replies and limited bandwidth to work on complex inquiries.
      The normal support hours are from 9:00 AM Eastern until 6:00 PM Eastern, Monday through Friday.

      The Time[0] series is available in OnBarUpdate as this is the time of the bar. This is not something that would be used in OnStateChange(). The Time series will not exist in State.Configure.

      When you mention: "With on bar, the values don't match". This would be expected. The indicator is being called at different times using different values supplied as the parameters. Different parameters will produce different values. Calling an indicator at different times, will produces values at that time which will different than calling an indicator at a different time.

      if ((ToTime(Time[0]) >= 93000 && ToTime(Time[0]) < 110000))
      {
      currentVWAP = amaCurrentDayVWAP(Close, amaSessionTypeVWAPD.Custom_Hours, amaBandTypeVWAPD.Standard_Deviation, amaTimeZonesVWAPD.US_Eastern_Standard_Time, @"09:30", @"11:00", 1, 2, 3, 1, 2, 3);
      }
      Is not the same as:
      else if ((ToTime(Time[0]) >= 110000 && ToTime(Time[0]) < 120000))
      {
      currentVWAP = amaCurrentDayVWAP(Close, amaSessionTypeVWAPD.Custom_Hours, amaBandTypeVWAPD.Standard_Deviation, amaTimeZonesVWAPD.US_Eastern_Standard_Time, @"11:00", @"12:15", 0.7, 1.25, 3, 0.7, 1.25,3);
      }
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Thanks for the response.
        Are we to assume then that the above is not possible ?
        The workaround for me was to define multiple currentvwaps in the above scenario which works, but I was trying to make it a bit elegant instead of having so many instances.
        Cheers!

        Comment


          #5
          Hello kashmiami,

          If you are calling an indicator with different parameters it would not be expected for the values to be same. Different data, different parameters, will return different values.

          That is nature of how data calculations work.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          93 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          48 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          31 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          34 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          69 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X