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 Mindset, 04-21-2026, 06:46 AM
          0 responses
          88 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          135 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          68 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          119 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          69 views
          0 likes
          Last Post PaulMohn  
          Working...
          X