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

condition

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

    condition

    Hello .
    Am I correct to describe the condition :
    if (Close[1]> Open[1] ==Open[0]> Close[0] ) ; ???
    See attachment:
    Attached Files
    Last edited by alex@n; 04-13-2017, 01:40 AM.

    #2
    Hello alex@n, and thank you for your question. to describe this situation you will want to use && instead of ==, so that your statement becomes

    Code:
    if (Close[1] > Open[1] [B]&& [/B]Open[0] > Close[0])
    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Hello JessicaP ,
      thank you for your answer,
      if (Close[1] > Open[1] && Open[0] > Close[0]) , No, it does not fit.
      See attachment:https://www.screencast.com/t/NjHEKqF1ea

      Comment


        #4
        Can you clarify what is meant by error in this case? The picture I am seeing draws a blue diamond over every red bar following a green bar.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Conditions
          Close[1] Bull bar == Open[0] Bear bar .
          Last edited by alex@n; 04-13-2017, 09:23 AM.

          Comment


            #6
            Thank you. Let's go ahead and put what we want into plain language. Please correct me if I'm wrong. Our goal is to detect the situation where

            • The previous bar is bullish and the current bar is bearish
            • The candlestick shapes of the previous bar and current bar are the same

            If this is the case, the condition I gave you before handles the first bullet only. In plain language, when we say that the previous bullish bar has the same candlestick shape as the current bearish bar, we mean that all of the following are true :


            • The previous bullish bar's close is equal to the current bearish bar's open
            • The previous bullish bar's open is equal to the current bearish bar's close
            • The previous bullish bar's high is equal to the current bearish bar's high
            • The previous bullish bar's high is equal to the current bearish bar's high

            So we can put everything together like this


            Code:
            if (
                // The previous bar is bullish and the current bar is bearish
                (Close[1] > Open[1] && Open[0] > Close[0])
            
            
                // The candlestick shapes of the previous bar and current bar are the same
                && (Close[1] == Open[0])
                && (Close[0] == Open[1])
                && (High[1] == High[0])
                && (Low[1] == Low[0])
                )
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_JessicaP View Post
              Thank you. Let's go ahead and put what we want into plain language. Please correct me if I'm wrong. Our goal is to detect the situation where

              • The previous bar is bullish and the current bar is bearish
              • The candlestick shapes of the previous bar and current bar are the same

              If this is the case, the condition I gave you before handles the first bullet only. In plain language, when we say that the previous bullish bar has the same candlestick shape as the current bearish bar, we mean that all of the following are true :


              • The previous bullish bar's close is equal to the current bearish bar's open
              • The previous bullish bar's open is equal to the current bearish bar's close
              • The previous bullish bar's high is equal to the current bearish bar's high
              • The previous bullish bar's high is equal to the current bearish bar's high

              So we can put everything together like this


              Code:
              if (
                  // The previous bar is bullish and the current bar is bearish
                  (Close[1] > Open[1] && Open[0] > Close[0])
              
              
                  // The candlestick shapes of the previous bar and current bar are the same
                  && (Close[1] == Open[0])
                  && (Close[0] == Open[1])
                  && (High[1] == High[0])
                  && (Low[1] == Low[0])
                  )
              Thank you !

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by algospoke, Today, 06:40 PM
              0 responses
              9 views
              0 likes
              Last Post algospoke  
              Started by maybeimnotrader, Today, 05:46 PM
              0 responses
              7 views
              0 likes
              Last Post maybeimnotrader  
              Started by quantismo, Today, 05:13 PM
              0 responses
              7 views
              0 likes
              Last Post quantismo  
              Started by AttiM, 02-14-2024, 05:20 PM
              8 responses
              168 views
              0 likes
              Last Post jeronymite  
              Started by cre8able, Today, 04:22 PM
              0 responses
              10 views
              0 likes
              Last Post cre8able  
              Working...
              X