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

OnBarUpdate() did not trig

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

    #16
    Hello Kobi,

    Thank you for your response.
    Originally posted by levikNT View Post
    1. From your previous answer you said that "Only when the variable you need to access does not have an IDateSeries type would you need to use the Update() method.", so the "Swing" indicator has a property of DataSeries type "public DataSeries SwingLow" and there is a call to Update() in order to force the OBU ,so according to your answer there is no need to call Update() .
    So there is a conflict between your answer to the Swing Code?
    There is no conflict, I am just not explaining this very clear. The Update() is used when you don't have an IDateSeries for the variable type, yet that does not mean you can't use it to update a DataSeries.
    Originally posted by levikNT View Post
    2. You said that "Using the barsAgo index would in fact call the OnBarUpdate() for that indicator" ,so my question is If the Update( ) is forcing the call to the OnBarUpdate() and using the barsAgo index also would call the OnBarUpdate() , so which statement is preferred for barsAgo = 0 (the last bar)
    For the the last bar I would use the barsAgo index for the indicator method. I would like to clarify though on one item. The Update() is generally is used in the indicator itself not the indicator that calls the indicator's variable. For example; indicator A has the variable I want, I set Update() in indicator A and when I call indicator A in indicator B I do not have an Update() used in indicator B.

    I hope this helps to clear this up. If not please let me know.

    Comment


      #17
      Originally posted by NinjaTrader_PatrickH View Post
      Hello Kobi,

      Thank you for your response.

      There is no conflict, I am just not explaining this very clear. The Update() is used when you don't have an IDateSeries for the variable type, yet that does not mean you can't use it to update a DataSeries.

      For the the last bar I would use the barsAgo index for the indicator method. I would like to clarify though on one item. The Update() is generally is used in the indicator itself not the indicator that calls the indicator's variable. For example; indicator A has the variable I want, I set Update() in indicator A and when I call indicator A in indicator B I do not have an Update() used in indicator B.

      I hope this helps to clear this up. If not please let me know.
      Hi PatrickH,

      last questions regarding this Item

      1. I understand that basically the Update() is used in the indicator the problem is if I need to access several variables and I set the CalculateOnBarClose = false; then The OnBarUpdate() will called several times instead of one. this will decrease performance!

      2. Again why there is a call to Update() to force calling the OBU in the swing property ?

      3. What the benefit of using the barsAgo index for the indicator method instead of Update() for the last bar, I understand that the Update() is generally used inside the indicator but Why? why it is not recommended to use from anther indicator?

      again I understand How NT use the Update() but I do not understand WHY?

      Thanks, Kobi

      Comment


        #18
        Hello Kobi,

        Thank you for your response.

        You have hit the nail on the head with your first item here. Your idea of just calling the indicator when needed rather than on every tick (CalculateOnBarClose = false) would be one of the main reasons to use Update() rather than calling the barsAgo index.

        So in the example of the Swing indicator we have two syntax that are used when calling the Swing from another indicator or from a strategy. Those two syntax are the following:
        Swing(int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod)
        Swing(int strength).SwingHigh[int barsAgo]
        The first being used to call the int value of barsAgo that tells us how many bars ago the Swing High occurred, and the second calling the actual (double) value of the Swing High. So the Update() here allows us to call the Swing indicator for the bars ago value without loading the indicator as we have specific parameters to determine the bars to start looking back from (int barsAgo), the instance of the Swing High (int instance), and the number of bars to look back starting from the int barsAgo (int lookBackPeriod).

        So why does the DataSeries have an Update() call for both swingHighSeries/swingLowSeries and SwingHighPlot/SwingLowPlot? So that we can call the barsAgo of the Swing High or Low and ensure that it's DataSeries value is up to date as well, thus ensuring our barsAgo value is accurate.

        The barsAgo Index is used in items like Close, Open, High and Low as these are DataSeries that we need the most recent double value of. Yet if I had a value that does not need a DataSeries or does not have one, we could use Update() in the properties region of that indicator to ensure that if it is called it is up to date. Like in the example of the Swing indicator, why have an IntSeries store a value on each bar update when we can just update it when needed with Update(), which in it's self is a picture of efficiency in programming.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, 04-17-2024, 06:40 PM
        3 responses
        26 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by bmartz, 03-12-2024, 06:12 AM
        3 responses
        27 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by Aviram Y, Today, 05:29 AM
        2 responses
        8 views
        0 likes
        Last Post Aviram Y  
        Started by gentlebenthebear, Today, 01:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by cls71, Today, 04:45 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X