Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Thinkscript fold equivalent in ninja

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

    Thinkscript fold equivalent in ninja

    Hi there,

    Looking for thinkscript fold equivalent in ninja, here is my simple thinkscript logic:

    def data = fold i = 0 to 10
    with s
    do s + (if Close > getValue(Open, i)
    then 1
    else if Close < getValue(Open, i)
    then - 1
    else 0);​

    #2
    Hello csrkkalyan,

    I am not certain on how that logic would execute, is that executing a loop from 0 to 10? Can you provide an explanation of what the variable data is and how that is used? That does not appear to be used in the following lines that you provided. The parts below def data appear to be if conditions, can you confirm that as well?



    Comment


      #3
      Hi Jesse,

      Thanks for your response. Yes, this is kind of looping concept. The fold operator allows you to perform iterated calculations.​ examples can be found from below url:

      Comment


        #4
        Hello csrkkalyan,

        The equivelent of that in C# would be a for loop. You can read about C# for loops here:

        C# iteration statements (for, foreach, do, and while) repeatedly execute a block of code. You use those statements to create loops or iterate through a collection.


        Code:
        for (int i = 0; i <= 10; i++)
        {​
        
        }

        Comment


          #5
          Thanks, this helps.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          56 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          133 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          73 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          49 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X