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

Intinger values can not be called in OnRender()

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

  • NinjaTrader_Gaby
    replied
    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

    Leave a comment:


  • Stanfillirenfro
    replied
    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.

    Leave a comment:


  • NinjaTrader_Gaby
    replied
    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.

    Leave a comment:


  • Stanfillirenfro
    replied
    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()?

    Leave a comment:


  • NinjaTrader_Gaby
    replied
    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

    Leave a comment:


  • Stanfillirenfro
    replied
    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!

    Leave a comment:


  • NinjaTrader_Gaby
    replied
    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.

    Leave a comment:


  • 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.

Latest Posts

Collapse

Topics Statistics Last Post
Started by WHICKED, 06-27-2023, 12:07 PM
84 responses
867 views
1 like
Last Post WHICKED
by WHICKED
 
Started by sofortune, 06-13-2024, 02:31 AM
3 responses
24 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by GodAtum, Today, 09:52 AM
11 responses
25 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by TheTechnician86, Yesterday, 10:44 PM
2 responses
13 views
0 likes
Last Post TheTechnician86  
Started by flonkle, Today, 01:19 AM
4 responses
29 views
0 likes
Last Post flonkle
by flonkle
 
Working...
X