Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Disable auto loop

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

    Disable auto loop

    Can I disable the auto loop so that I start from the oldest bar instead of the latest bar using a manual loop?

    Call it a learning disability, but I'm trying to adapt some of my VB.net code and I'm having a hard time thinking "backwards in time".

    Thanks,

    Paul

    #2
    Not sure I follow...What is an auto loop?
    RayNinjaTrader Customer Service

    Comment


      #3
      implied loop in ninja script

      In Ninja script you don't have to explicitly include a "for loop", you just enter what you want to calculate, indexed from the most recent bar. For example, if is want to calulate the different between todays close versus yesterdays close I would include the following line in the body of the code.

      Close(0) - Close(1)

      There is an implied loop already written into the script. What I want is to disable this part so I can do my calculation starting from the oldest bar. Like this

      Code:
       
      for (i=0; i < #ofbars; i++)
      {
      Close(i) - Close(i-1)
      }
      Thanks

      Comment


        #4
        Try something like this:

        Code:
        [FONT=Courier New][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] ([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] index = Count -[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; index >= [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; index--) [/SIZE][/FONT]
        [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
        [SIZE=2][FONT=Courier New]Print(Close[index]);[/FONT][/SIZE]
        [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        43 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        25 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        162 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        98 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        158 views
        2 likes
        Last Post CaptainJack  
        Working...
        X