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

how to add a !=

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

    how to add a !=

    Hello,
    I'm modifying an entry signal to not enter when High[0] is also the high of the day. I though I could add High[0] != CurrentDayOHL().CurrentHigh[0], but that doesn't change anything when its the high of the day. Here is my code:
    if (Position.MarketPosition == MarketPosition.Flat
    && SwingHighCross > -1 && (CrossAbove(TrendStrengthA(VC.NinjaScript.Utility. MovingAverageType.VWMA, 200, 20, 10).TrendStrength, 60, 4)
    || CrossAbove(TrendStrengthA(VC.NinjaScript.Utility.M ovingAverageType.VWMA, 200, 20, 10).TrendStrength, -60, 4)
    && High[0] != CurrentDayOHL().CurrentHigh[0]))
    Any ideas as to why the Enter() would still fire when it's the day high?

    #2
    Hi CaptainAmericaXX,

    Your condition says buy when they are not equal to each other. You may want instead < to check that it is lower.

    if (High[0] < CurrentDayOHL().CurrentHigh[0])
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ah, yes of course. != means not equal to. Silly mistake. How would one say
      if(High[0] == CurrentDayOHL().CurrentHigh[0])
      no trade, when my other conditions may be true at that time.?

      Comment


        #4
        I feel < is the most appropriate here. It checks that the current bar's high is lower than the current session high, which seems to be what you want to express.

        Otherwise, print both values and determine what type of comparison you want to make.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I'm sorry I didn't explain my idea very well. There is a specific set up I'm trying catch that happens better when the market is trading inside the session high and low. When price is making new highs or lows this set up doesn't work. If a new session high is made in the current bar and my other conditions call for a buy I don't want to take that trade. I did however follow your advice and put in < instead of == and there was no change. I certainly appreciate any other suggestions you can give.

          Comment


            #6
            Originally posted by CaptainAmericaXX View Post
            I'm sorry I didn't explain my idea very well. There is a specific set up I'm trying catch that happens better when the market is trading inside the session high and low. When price is making new highs or lows this set up doesn't work. If a new session high is made in the current bar and my other conditions call for a buy I don't want to take that trade. I did however follow your advice and put in < instead of == and there was no change. I certainly appreciate any other suggestions you can give.
            You are definitely going to need to use some print statements on all those values to the console to debug that statement.

            Comment


              #7
              If you're checking this historically it may not work as you expect. CurrenDayOHL() is available for the current session only.

              If you need to check an intraday high compared to a daily high historically, then you can work in multiseries framework to a add a daily series.

              Ryan M.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by geddyisodin, Yesterday, 05:20 AM
              8 responses
              49 views
              0 likes
              Last Post geddyisodin  
              Started by DayTradingDEMON, Today, 09:28 AM
              3 responses
              19 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by Stanfillirenfro, Today, 07:23 AM
              9 responses
              23 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by George21, Today, 10:07 AM
              0 responses
              8 views
              0 likes
              Last Post George21  
              Started by navyguy06, Today, 09:28 AM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Working...
              X