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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          43 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          20 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          29 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          46 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          38 views
          0 likes
          Last Post CarlTrading  
          Working...
          X