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 LavniaCardos, Today, 02:32 AM
      0 responses
      1 view
      0 likes
      Last Post LavniaCardos  
      Started by pstrusi, 11-13-2022, 05:23 PM
      23 responses
      398 views
      0 likes
      Last Post pstrusi
      by pstrusi
       
      Started by Murphy67, Today, 01:10 AM
      2 responses
      12 views
      0 likes
      Last Post DiverG20  
      Started by DiverG20, Today, 02:01 AM
      0 responses
      4 views
      0 likes
      Last Post DiverG20  
      Started by AlexEro, Today, 12:29 AM
      0 responses
      8 views
      0 likes
      Last Post AlexEro
      by AlexEro
       
      Working...
      X