Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How many Bars?

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

    How many Bars?

    Multi Bar Strat:

    I used to say:


    if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired || CurrentBars[2] < BarsRequired || CurrentBars[3] < BarsRequired ||CurrentBars[4] < BarsRequired ||)
    {return;}


    and in so doing, I would never know which Bar was lacking in quantity.

    I now say:

    if (CurrentBars[0] < BarsRequired){Print("0");return;} //tick
    if (CurrentBars[1] < BarsRequired){Print("1");return;} //day
    if (CurrentBars[2] < BarsRequired){Print("2");return;} //min
    if (CurrentBars[3] < BarsRequired){Print("3");return;} //sec
    if (CurrentBars[4] < BarsRequired){Print("4");return;} //10 min



    so that I know.

    As it is, It seems that no matter how many Day bars I load, whichever bar is a day bar prints its BarsArray number due to lack of bars available (Chart calls for 5 but you only have 4 error).

    Am I doing something egregiously wrong? If I load 3 days of data, and only need to calculate yesterday's Pivot Point, I set bars required to 1, and I get an error print on Bar 1 (day).

    If I am calcing a 10 day SMA of volume, and I load 10 days of data, I get an error on Bar 1 (day).

    If I am doing an intraday calc, and I load 2 days of data with two bars required, I get an error on Bar 1 (day).

    I am obviously making a wholesale mistake because this happens Ad Nauseum. I have read the multibar strategy page in help dozens of times...

    What am I missing?

    Regards,

    Andrew;}

    #2
    Hello Andrew,
    Thanks for your note.

    By default BarsRequired = 20; thus if you are loading 5 days of data, then then only 5 bars (even less if there is weekend) are being loaded for the Day = 1. Thus you are witnessing the scenario.

    I would suggest loading the data as:
    • Right click on the chart
    • In the context menu click on Data Series
    • In the Data Series dialog set the field "Load data based on" to Bars
    • Set the field "Bars to load to say 50


    Please try loading the code and see if you are able to run it or not.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Joydeep: does a saturday or sunday count as one bar?? I thought the default was to count trading days only...am I wrong?

      Regards,

      Andrew

      Comment


        #4
        Hello Andrew,
        If you load the data as Bars then NinjaTrader will load X bars, however if you load the data as Days, then NinjaTrader will load the data from X date to Y date.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Very good. TY as always Joydeep.

          Regards.

          Edit: Final question: assuming I am not charting, how do i code this syntactically for a group of ten stocks that use the same strategy?

          Is there a line i can use within initialize?

          Regards.
          Last edited by alabell; 11-27-2012, 01:23 PM.

          Comment


            #6
            Actually, that remains an issue how to do this "outside of a chart" as i referenced below..?

            Comment


              #7
              Originally posted by alabell View Post
              Very good. TY as always Joydeep.

              Regards.

              Edit: Final question: assuming I am not charting, how do i code this syntactically for a group of ten stocks that use the same strategy?

              Is there a line i can use within initialize?

              Regards.
              Have a look at this post: http://www.ninjatrader.com/support/f...515#post311515 in this thread: http://www.ninjatrader.com/support/f...507#post311507

              Comment


                #8
                TY Koganam. I will review this.

                Best regards,

                Andrew

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by rocketman7, Today, 09:41 AM
                2 responses
                4 views
                0 likes
                Last Post rocketman7  
                Started by traderqz, Today, 09:44 AM
                1 response
                2 views
                0 likes
                Last Post traderqz  
                Started by rocketman7, Today, 02:12 AM
                7 responses
                31 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by guillembm, Yesterday, 11:25 AM
                3 responses
                16 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by junkone, 04-21-2024, 07:17 AM
                10 responses
                149 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Working...
                X