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

Daily SMA indicator

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

    #16
    sorry but I can't determine whats wrong & run out of time.

    simplified indicator attached.

    error thrown when scrolling fully to left.

    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnBarUpdate()
     {
     [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2](BarsInProgress == [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] && FirstTickOfBar)
     {
     curPeriod = Math.Min(CurrentBars[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]], SMAPeriod);
     }
     [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2](BarsInProgress == [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])
     {
     Value.Set(High[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]]);
     }
     }
    [/SIZE][/FONT][/SIZE][/FONT]
    Attached Files
    Last edited by futurenets; 02-13-2015, 12:41 PM.

    Comment


      #17
      Hello,

      I wanted to check with you,

      This is a different indicator than the prior one that was uploaded. I imported this item and it is plotting, was there a question for this new indicator? I tried the chart settings as previously discussed and moved the chart to the start and it is still plotting.

      Otherwise the answer for the first indicator is in post #14, I am not sure on the math you are using but when printing the values I see that it is not producing a number but infinity instead.

      You can use Print() statements to determine this, if the new indicator is having a similar problem you can locate that problem by printing the values to ensure they are valid.

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #18
        yes it plots and also throws an error when scrolling fully to left.

        I use debugview but you can use print to see this.

        sorry but I've run out of time so cut out everything to make it easier to solve.

        I think the problem lies within

        curPeriod = Math.Min(CurrentBars[1], SMAPeriod); ???

        removing this removes the error
        Last edited by futurenets; 02-13-2015, 12:51 PM.

        Comment


          #19
          Hello,

          Can you please provide a working script with what you are printing?

          I do not see errors when trying to print curPeriod, I am not sure what you are printing.

          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #20
            ok thanks Jesse

            I'll take another look when I have more time.

            Comment


              #21
              thanks again for help.

              initialization problem fixed and working.

              can I ask what order are Bar objects processed e.g.

              BarsInProgress == 1

              then

              BarsInProgress == 0

              i.e. higher to lower?
              Last edited by futurenets; 02-14-2015, 06:17 AM.

              Comment


                #22
                Originally posted by futurenets View Post
                thanks again for help.

                initialization problem fixed and working.

                can I ask what order are Bar objects processed e.g.

                BarsInProgress == 1

                then

                BarsInProgress == 0

                i.e. higher to lower?
                Neither and both. As with all event-based programming, it is the event (in this case, a tick arrival) that is processed. The tick is queried for which BarSeries generated it, then the relevant code is run based on that.

                Comment


                  #23
                  when I add the attached DailyWMA to a daily chart and compare it with a WMA the DailyWMA is a day behind.

                  This is what I want but I don't understand why it's happening?

                  Thanks again.
                  Attached Files

                  Comment


                    #24
                    Originally posted by koganam View Post
                    Neither and both. As with all event-based programming, it is the event (in this case, a tick arrival) that is processed. The tick is queried for which BarSeries generated it, then the relevant code is run based on that.
                    ok but if 2 bar objects exist for same symbol will not the ticks be from the same source?

                    Comment


                      #25
                      Originally posted by futurenets View Post
                      ok but if 2 bar objects exist for same symbol will not the ticks be from the same source?
                      Yes, if CalculateOnBarClose is false. in which case the code will be run in the order that it is written, because there is, ipso facto, no branching involved.

                      ref: http://www.ninjatrader.com/support/h...nstruments.htm

                      Comment


                        #26
                        Originally posted by koganam View Post
                        Yes, if CalculateOnBarClose is false. in which case the code will be run in the order that it is written, because there is, ipso facto, no branching involved.

                        ref: http://www.ninjatrader.com/support/h...nstruments.htm
                        sorry don't understand?

                        Comment


                          #27
                          Originally posted by futurenets View Post
                          sorry don't understand?
                          I gave you a reference. It seems clear enough to me. If you do not understand what the reference explains, I am unable to help any further. My apologies.

                          Code will always run in the order that it is written, so that is all that gates the code. Yes, even in so-called parallel processing systems, that run on anything other than a cluster, code will run serially once the event that triggers the code arrives. Events arrive in any order, but the code that handles the event will always run serially, as written. In the case of NinjaTrader handling ticks from the same instrument, the reference clearly explains that NT caches the event, to save processing resources. That is how NT internally manages to handle the same tick as belonging to different BarSeries, when it so does.
                          Last edited by koganam; 02-15-2015, 10:10 AM.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by GussJ, 03-04-2020, 03:11 PM
                          16 responses
                          3,279 views
                          0 likes
                          Last Post Leafcutter  
                          Started by WHICKED, Today, 12:45 PM
                          2 responses
                          19 views
                          0 likes
                          Last Post WHICKED
                          by WHICKED
                           
                          Started by Tim-c, Today, 02:10 PM
                          1 response
                          8 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by Taddypole, Today, 02:47 PM
                          0 responses
                          5 views
                          0 likes
                          Last Post Taddypole  
                          Started by chbruno, 04-24-2024, 04:10 PM
                          4 responses
                          51 views
                          0 likes
                          Last Post chbruno
                          by chbruno
                           
                          Working...
                          X