Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help with NinjaScript

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

    Need help with NinjaScript

    Firstly, I'm new to ninjascript. However, i have been trying to figure out how to track a certain pattern on my chart (see below).

    For example, here is my code (simplified):

    If (A) // first occurrence of "A" pattern on the chart
    {
    B = high[0]
    A1 = True
    }

    If ((A) // that is, if "A" happens again - the second occurrence of "A" pattern on the chart
    && A1 == True
    && High > B ) // which never returns - True. Always, returning False.
    {
    C = high[0]
    B1 = True
    }

    The problem with the above code is this line "&& High > B​". It is never true because whenever "A" is True,it assigns the High[0} to B. Thus, the High[0] is never greater than "B".

    How do I keep track of multiple instances of "A" occurring? I'm trying to track each instances of "A" occurring independently.

    Specifically, I want to independently track the pattern below each time it occurs on my chart.

    if((Close[0] < Open[0])
    && (Close[1] < Open[1])
    && (Close[2] > Open[2])
    && (Close[3] > Open[3]) )

    Your assistance will be greatly appreciated.

    #2
    Hello cryfgg,

    Your If (A) condition can keep happening past the first occurrence. You need
    Code:
    If (A && A1 == false)
    to check for a first occurrence.

    You can additionally use B1:

    Code:
    If (A && A1 == false && B1 == false)
    When you need this to work again you need to set A1 and B1 to false.

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello cryfgg,

      Your If (A) condition can keep happening past the first occurrence. You need
      Code:
      If (A && A1 == false)
      to check for a first occurrence.

      You can additionally use B1:

      Code:
      If (A && A1 == false && B1 == false)
      When you need this to work again you need to set A1 and B1 to false.
      I think I know what to do. Thanks... have a fantastic Weekend.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      656 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      371 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      574 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      579 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X