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

why this simple code will fail?

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

    why this simple code will fail?

    I am trying to write my first indicator, inside day
    but try hard and always fail
    can any one help?
    thanks

    protected override void OnBarUpdate()
    {
    if (CurrentBar < 1) return ;
    if (High[0] < High[1] && Low[0] > Low[1])
    ID[0] = 1 ; // inside
    else if (High[0] > High[1] && Low[0] < Low[1])
    ID[0] = -1 ;// outside
    else
    ID[0] = 0 ; // neither
    }
    Last edited by manson4134; 12-02-2016, 05:36 PM.

    #2
    Hello manson4134,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    Check your Log tab on the Control Center, likely an error is present on not having the data available before accessing it. Please refer to the post at the following link for more information: http://ninjatrader.com/support/forum...ead.php?t=3170

    If you have any questions please let me know.

    Comment


      #3
      Originally posted by manson4134 View Post
      if(High[0] < High[1] && Low[0] > Low[1]) // inside day
      ID_bar=1;
      else
      ID_bar=-1;

      ID[0]=ID_bar; //draw ID on chart window but show nothing
      Since you'll need to have a least 2 bars on the chart, check CurrentBar to make sure:
      Code:
              protected override void OnBarUpdate()
              {
                  if (CurrentBar < 1) return ;
                  if (High[0] < High[1] && Low[0] > Low[1])
                      ID[0] = 1 ; // inside 
                  else if (High[0] > High[1] && Low[0] < Low[1])
                      ID[0] = -1 ;// outside 
                  else
                      ID[0] = 0 ; // neither
              }

      Comment


        #4
        Thank you!

        Originally posted by NinjaTrader_PatrickH View Post
        Hello manson4134,

        Thank you for your post and welcome to the NinjaTrader Support Forum!

        Check your Log tab on the Control Center, likely an error is present on not having the data available before accessing it. Please refer to the post at the following link for more information: http://ninjatrader.com/support/forum...ead.php?t=3170

        If you have any questions please let me know.

        I already get it done, it work!
        Thanks both of you!!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bortz, 11-06-2023, 08:04 AM
        47 responses
        1,607 views
        0 likes
        Last Post aligator  
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        9 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        19 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        6 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        16 views
        0 likes
        Last Post Javierw.ok  
        Working...
        X