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 PhillT, Today, 02:16 PM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by Kaledus, Today, 01:29 PM
        3 responses
        9 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by frankthearm, Yesterday, 09:08 AM
        14 responses
        47 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by gentlebenthebear, Today, 01:30 AM
        2 responses
        13 views
        0 likes
        Last Post gentlebenthebear  
        Started by PaulMohn, Today, 12:36 PM
        2 responses
        17 views
        0 likes
        Last Post PaulMohn  
        Working...
        X