Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

several dataseries in onbarupdate

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

    several dataseries in onbarupdate

    Hello,

    I want to ask please how "to work more easily" with different dataseries in onbarupdate. Is it possible to have
    {
    if(BarsInProgress!=0) return;
    if(conditions...)
    }
    AND
    {
    if (BarsInProgress!=1) return;
    if (conditions...)
    }
    instead of work around in one "{ }" with [x] and [y] to refer to the dataseries in concern.

    The reason for my question is that I have some codings and indicators I can use easily like a primary dataseries but difficult to use them with different dataseries in one "{section}" (so that there is no confusion with bool, int and doubles)

    I hope I could translate and explain what I mean.

    Thank you
    Tony

    #2
    Hi tonynt,

    Thanks for your post.

    I think I understand generally what you are saying.

    Personally, I do think it is clearer when you organize your code by using:

    if (BarsInProgress == 0)
    {
    // all code here updates when chart bars update
    }
    if (BarsInProgress ==1)
    {
    all code here updates when 1st added dataseries updates
    }

    By using == you know exactly which bars is updating the code section.

    It very much depends on what you want your code to do. In some cases you may not need to use anything but if (BarsInProgress == 0) {} and then just refer to the other data series inside of the BIP = 0 section by busing the BarsArray[x] pointer. For example:

    if (BarsInProgress ==0)
    {
    // other code
    sma5minute = SMA(BarsArray[1], 20)[0]; // Get the current value of the SMA 20 from the 1st added data series even though we are updating on the chart bars
    }

    Hope that helps.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you for your reply.

      I worked untill now with ...BarsArray].... in my indicators but this is what I want to avoid.

      So, I understand that I can use different dataseries with BIP==x....

      What I mentioned in my question are the bool, int, double definitions. Do I have to put them

      if (BarsInProgress==1)
      HERE?
      or
      {
      HERE?
      }

      and do I have to use different names when I use them BIP==0 and also in BIP==1?

      Thank you
      Tony

      Comment


        #4
        Hello Tony,

        Thanks for your reply and clarity of your interests.

        To use your variables in all sections of the OnBarUpdate() you would want to declare them above OnBarUpdate(). Typically these would be declared just after public class Name : indicator

        For example:

        Code:
        	public class Bollinger : Indicator
        	{
        		#region Variables
        		private	double	numStdDev	= 2;
        		private       int		period		= 14;
        		#endregion
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hello Paul,

          thank you again for your reply. Sorry for causing confusion with asking incorrectly maybe. Let me try again please:

          when I use the indicator for BIP==0 and also for BIP==1 then I have to declare them only one time above? An indicator or criteria might be different for BIP0 and BIP1.

          In your example above with SMA(BarsArray[1],20) you also access accurately that dataseries. So why could I declare above onbarupdate when I need to have SMA(BarsArray[1],20) and SMA(BarsArray[2],.........? eg I need to catch the bid and ask at a low and high of the bar, and the high and low is different each dataseries. don´t I need to declare within each BIP?

          This was the core of my question that confuses me now.

          Thank you for your support!

          Tony

          Comment


            #6
            Hi Tony,

            Thanks for your post.

            You would declare, "What I mentioned in my question are the bool, int, double definitions. " in the region variables if you want to use them throughout onbarupdate.

            To avoid further confusion, please read the helpguide here: http://ninjatrader.com/support/helpG...nstruments.htm this is the best explanation, when read sequentially, to understand.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by martin70, 03-24-2023, 04:58 AM
            15 responses
            114 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by The_Sec, Today, 02:29 PM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by jeronymite, 04-12-2024, 04:26 PM
            2 responses
            31 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by Mindset, 05-06-2023, 09:03 PM
            10 responses
            265 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by michi08, 10-05-2018, 09:31 AM
            5 responses
            743 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X