Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    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 Davide999, 05-18-2023, 03:55 AM
      4 responses
      554 views
      1 like
      Last Post kcwasher  
      Started by Stanfillirenfro, Today, 07:23 AM
      2 responses
      9 views
      0 likes
      Last Post Stanfillirenfro  
      Started by rexsole, Today, 08:39 AM
      2 responses
      6 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      6 responses
      29 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by gbourque, Today, 06:39 AM
      2 responses
      14 views
      0 likes
      Last Post gbourque  
      Working...
      X