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 CaptainJack, 05-29-2026, 05:09 AM
          0 responses
          164 views
          0 likes
          Last Post CaptainJack  
          Started by CaptainJack, 05-29-2026, 12:02 AM
          0 responses
          85 views
          0 likes
          Last Post CaptainJack  
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          126 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          207 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          185 views
          0 likes
          Last Post CarlTrading  
          Working...
          X