NEXT

Category: Instructions

The NEXT instruction in ProBuilder language is used to mark the end of a loop block, specifically in FOR loops. It indicates that the loop should continue iterating until the specified condition is no longer met. The primary purpose of the NEXT instruction is to facilitate the repetition of a block of code a certain number of times, which is useful for aggregating or manipulating data sequentially.

Syntax:

FOR variable = start TO end DO
    [statements]
NEXT

Example:

a = 0
FOR i = 10 TO 20 DO
    a = average[i](open) + a
NEXT
RETURN a AS "compound averages direction"

In this example, the code calculates the sum of average open prices from index 10 to 20. The NEXT instruction signifies the end of the loop block that accumulates the averages into the variable a. After completing the iterations, the final value of a is returned as “compound averages direction”.

  • The FOR loop initializes with the variable i set to 10 and continues until i equals 20.
  • Within the loop, the average open price at each index i is added to the variable a.
  • The NEXT instruction causes the loop to increment the value of i and repeat the enclosed statements until i surpasses 20.

This instruction is crucial for performing repetitive tasks efficiently in financial data analysis, allowing for operations over a range of data points in a structured and clear manner.

Related Instructions:

  • BREAK instructions
  • DO instructions
  • DOWNTO instructions
  • FOR instructions
  • TO instructions
  • Logo Logo
    Loading...