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 bmartz, 03-12-2024, 06:12 AM
      5 responses
      32 views
      0 likes
      Last Post NinjaTrader_Zachary  
      Started by Aviram Y, Today, 05:29 AM
      4 responses
      13 views
      0 likes
      Last Post Aviram Y  
      Started by algospoke, 04-17-2024, 06:40 PM
      3 responses
      28 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by gentlebenthebear, Today, 01:30 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by cls71, Today, 04:45 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X