Announcement

Collapse
No announcement yet.

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 sjsj2732, Yesterday, 04:31 AM
              0 responses
              31 views
              0 likes
              Last Post sjsj2732  
              Started by NullPointStrategies, 03-13-2026, 05:17 AM
              0 responses
              286 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              283 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              133 views
              1 like
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              91 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Working...
              X