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

SampleGetBar Indicator

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

    SampleGetBar Indicator

    I looked at this post http://ninjatrader.com/support/forum...ad.php?t=19176 and installed this indicator on a chart using NT7 but I see no lines. In reading the code it appears as though the indicator should draw a line based on an SMA at 9:30am of the previous day. My chart shows no lines. Is this supposed to be used with some other data for it to work? Given that today is Friday, I change line #55 to read

    "if (Time[0].DayOfWeek == DayOfWeek.Friday)"

    but this did not help. What am I missing? Thanks!

    Best regards,

    Dolfan

    #2
    Hello Dolfan,

    Thanks for your post.

    In reviewing the indicator there is this note: This sample assumes instrument sessions that go from Monday-Friday and not the weekends. If you are using an instrument that has weekend trading sessions like the ES futures, please be aware that the logic presented will need to be modified to reflect the trading sessions for your particular instrument.

    I think the example was intended for stock type data.

    If you are looking at a futures instrument, to quickly observe the indicator functionality, to see the horizontal line drawn at yesterdays SMA, you can change the session template in the dataseries window to US Equities RTH.

    If you want to see more that just yesterday's SMA, you can change the "tag name" of the DrawLine from "yesterday SMA" to "yesterday SMA"+CurrentBar. (Line 72).
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      OK, here are my settings...

      Indicator - http://screencast.com/t/cZBIUs0zE
      Data Series - http://screencast.com/t/hueDEpb4Ph

      ...and still no line. What am I doing wrong here?

      Dolfan

      Comment


        #4
        Hello Dolfan,

        Thanks for your post.

        In review of the code of the SampleGetBar it appears that the line to be drawn is in Black which you would not see with a black background.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          So the settings in the indicator panel don't mean anything?

          I changed the color in the code to Cyan and still nothing. I removed the indicator from the chart before the change and reloaded after the change. NADA

          Comment


            #6
            Hello Dolfan,

            Thanks for your post.

            Correct, in the sample indicator the indicator parameters will only change the plot colors of the SMA line. The plotted reference line will be black unless you change it within the code.

            Attached is a charted example using 15 minute, CL 08-16 (with US equities RTHsession template used just to show the black line based on yesterdays SMA value at 9:30 AM).
            Attached Files
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I uninstalled the indicator and reinstalled it fresh and still it doesn't show. Can you send me your indicator and data series settings? Thanks!

              Dolfan

              Comment


                #8
                Hi Dolfan,

                The source file is attached but there is no change from what you downloaded.

                I detailed the instrument settings in my previous post. The main thing is to use the us equities RTH session to get it to show as mine did, although this late in the day even the regular session would show the black line somewhere. You may need to expand or contract your vertical scale to see it.
                Attached Files
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  SampleGetBar on NinjaTrader 8

                  Hello !
                  I was trying the Bars.GetBar() on Ninja 8 and can not make it to detect the correct bar as on the example
                  I modified the code to draw the line from the point where it is supposed the SMA is at 9:30
                  Draw.Line(this, "yesterday SMA", barsAgo, SMAPlot[barsAgo], 0, SMAPlot[barsAgo], Brushes.Red);
                  I attach an example of the chart where the starting point is neither the previous day or 9:30
                  I attach also the used code.
                  Can someone tell me if Im doing something wrong ?

                  Thanks !
                  Attached Files
                  pmaglio
                  NinjaTrader Ecosystem Vendor - The Indicator Store

                  Comment


                    #10
                    Hello pmaglio,

                    Thanks for your post.

                    It does appear that something is not working correctly either in the coded sample or in the GetBar() method for NT8. We will investigate and update this thread when we have further information. Thank-you for reporting your observations.

                    Please note that we are asking all NT8 users to post their questions in the NT8 beta forums, thanks in advance for your understanding.
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello pmaglio,

                      After further review there are two issues with what you are trying to do:

                      First is that you are using an index (YM) that runs a session starting Sunday evenings. In the notes within the file SampleGetBar.cs advise the following: "This sample assumes instrument sessions that go from Monday-Friday and not the weekends. If you are using an instrument that has weekend trading sessions like the ES futures, please be aware that the logic presented will need to be modified to reflect the trading sessions for your particular instrument.
                      Here, timeOfInterest is reset once per day at session break.

                      You can quickly test this by changing the session template to US Equities RTH which are a Monday-Friday only.

                      Secondly, it appears the coding for the draw.line is incorrect and we will implement a change in our sample. To accomplish your goals you will need to use:

                      Draw.Line(this, "yesterday SMA", CurrentBar - barsAgo, SMAPlot[CurrentBar - barsAgo], 0, SMAPlot[CurrentBar - barsAgo], Brushes.Red);
                      Paul H.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by algospoke, Today, 06:40 PM
                      0 responses
                      9 views
                      0 likes
                      Last Post algospoke  
                      Started by maybeimnotrader, Today, 05:46 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post maybeimnotrader  
                      Started by quantismo, Today, 05:13 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post quantismo  
                      Started by AttiM, 02-14-2024, 05:20 PM
                      8 responses
                      168 views
                      0 likes
                      Last Post jeronymite  
                      Started by cre8able, Today, 04:22 PM
                      0 responses
                      10 views
                      0 likes
                      Last Post cre8able  
                      Working...
                      X