Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Intinger values can not be called in OnRender()

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

    Intinger values can not be called in OnRender()

    Hello!
    I have cerated a section region helpers in which I hve some calculations using Series<int>. Iwanted to call these values in OnRender() for drawing purpuses.
    I have use the print function in the region helpers ass well as in OnRender() to vue if there is any mistake. The print function pups up the values from the region helpers which are different from zero, but those from OnRender() have the value zero.
    Here is the snapshot of the code:
    HTML Code:
     #region Variables
       private Series<int> strength;
    
       if (State == State.DataLoaded)
       {
         strength = new Series<int>(this);
       }
    #endregion
       #region Helpers
         strength[count] = temp_strength[i];
         Print("strength" + " Size " + ":  " + strength[count]);
      #endregion
    
      protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
      {
        for(int idx = 0; idx < count; idx++)
        {
          int valStrength = strength.GetValueAt(idx);
          Print("ValStrength" + " Size " + ":  " + ValStrength);
        }
      }
    I would highly appreciate if someone could point out where I am mistaking.

    Best regards,
    Last edited by Stanfillirenfro; 04-22-2024, 09:23 AM.

    #2
    Hello Stanfillirenfro,

    Thank you for your post.

    Where is the Helpers region in relation to the rest of the code? When are the strength values being assigned? Is possible they are being assigned after you are trying to get the value in OnRender?

    Are the values returning null, or 0?

    I look forward to assisting further.

    Comment


      #3
      Many thanks NinjaTrader_Gaby for your reply.

      Where is the Helpers region in relation to the rest of the code?
      The region Helpers comes directly after OnBarUpdate() and directly before OnRender().

      When are the strength values being assigned?
      They are assigned in the region Helpers.
      Is possible they are being assigned after you are trying to get the value in OnRender?
      No! It is the reason why I have OnRender() after region Helpers.
      Are the values returning null, or 0?
      The values are returning 0.

      Thanks in advance!

      Comment


        #4
        Hello Stanfillirenfro,

        Is this Helpers region just outside of any method? This would mean this code is likely only being executed once. It's not going to be assigning an updated value to the series on every pass of OnBarUpdate() or OnRender() if it is outside of any methods.

        It would be better to assign the series a value from a method like OnBarUpdate(). Please see this example script demonstrating.
        Attached Files

        Comment


          #5
          Many thanks NinjaTrader_Gaby for your reply.

          In the example you have posted, the Series are assigned in OnBarUpdate().
          In my case, I am assigning my Series in region Helpers.

          Is there a way to assign values in region Helpers and to used them in OnRender()?

          Comment


            #6
            Hello,

            Thank you for your response.

            All logic must be inside a method. What method is your Helpers region located in? Is it inside OnStateChange and if so, is it inside a State.DataLoaded condition? If not, could you please specify where or provide a more complete example of your code so we can take a look?

            Thank you in advance.

            Comment


              #7
              Many hanks NinjaTrader_Gaby for your reply.

              HTML Code:
              protected override void OnBarUpdate()
              {
                 myZones();
              }
              
              #region Helpers       void myZones()
              {
                for(i = 0; i < temp_count; i++)
                {
                  strength[temp_count] = temp_strength[i];
                }
              }    #endregion
              Last edited by Stanfillirenfro; 04-22-2024, 01:49 PM.

              Comment


                #8
                Hello,

                If you are calling myZones() from OnBarUpdate(), it is possible to get the series values from OnRender().

                Please see the attached sample script demonstrating. If you are unable to get this to work in your own script, you will need to debug using prints.

                This guide goes over how to use prints to debug: https://support.ninjatrader.com/s/ar...nd-TraceOrders

                Please let us know if you have any further questions.
                Attached Files

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NinjaTrader_Brett, 05-12-2025, 03:19 PM
                0 responses
                218 views
                0 likes
                Last Post NinjaTrader_Brett  
                Started by domjabs, 05-12-2025, 01:55 PM
                2 responses
                50 views
                0 likes
                Last Post domjabs
                by domjabs
                 
                Started by Morning Cup Of Trades, 05-12-2025, 11:50 AM
                1 response
                54 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Started by imjustkaze, 05-12-2025, 12:20 PM
                2 responses
                90 views
                0 likes
                Last Post imjustkaze  
                Started by IanS00, 05-12-2025, 11:57 AM
                3 responses
                33 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Working...
                X