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

MIN & MAX not triggering

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

    MIN & MAX not triggering

    Hello,

    Can you please help me identify the problem?

    I am trying the following conditions, but there is no trigger.

    Code:
    double VWAPStdDevUp1 = OrderFlowVWAP(VWAPResolution.Tick, Bars.TradingHours, VWAPStandardDeviations.Three, 1, 2, 3).StdDev1Upper[0];
                   
                    MAX1                = MAX(High, 2);
                    MIN1                = MIN(Low, 2);
                    Print(string.Format("High: {0}, Low: {1}",  MAX1[0], MIN1[0]));
                    
                
                    if (CrossAbove(Close, MAX1,1) && Closes[0][0] < VWAPStdDevUp1)​

    #2
    Can you please state what you're trying to do in English?

    I mean, describe your conditions, very specifically, so that
    we can understand what conditional state you're trying to
    capture.

    Comment


      #3
      I am getting the highest High of the last 2 bars. After that,
      I want a long entry once the close price cross above the Highest High and the price is under the 1st upper deviation line

      thanks

      Comment


        #4
        Originally posted by Jorge.andres.o View Post
        I am getting the highest High of the last 2 bars. After that,
        I want a long entry once the close price cross above the Highest High and the price is under the 1st upper deviation line
        Assuming Calculate.OnBarClose ...

        Code:
        if (Close[0] > Math.Max(High[1], High[2]) && Close[0] < VWAPStdDevUp1)
            ...

        Comment


          #5
          Can I calculate it on each tick?

          Comment


            #6
            Hmm, let me see ...

            As a matter of fact, yep, it should work fine.

            Do you understand why?

            Let's review,

            OnPriceChange/OnEachTick:
            Close[0] is close of active bar being built (basically last price seen)
            Close[1] is close of prior bar (basically most recently closed bar)
            Close[2] is close of previous prior bar

            OnBarClose:
            Close[0] is close of most recently closed bar
            Close[1] is close of prior bar
            Close[2] is close of previous prior bar

            So, yep, that if statement I provided should work
            fine for all Calculate settings.

            -=o=-

            Make sure you have a guard for CurrentBar
            somewhere near the top of your OnBarUpdate.

            At the minimum, you'll need,

            Code:
            if (CurrentBar < 2)
                return;
            Make sense?

            Comment


              #7
              You’re awesome thanks a lot for your help with the code

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Segwin, 05-07-2018, 02:15 PM
              14 responses
              1,789 views
              0 likes
              Last Post aligator  
              Started by Jimmyk, 01-26-2018, 05:19 AM
              6 responses
              837 views
              0 likes
              Last Post emuns
              by emuns
               
              Started by jxs_xrj, 01-12-2020, 09:49 AM
              6 responses
              3,293 views
              1 like
              Last Post jgualdronc  
              Started by Touch-Ups, Today, 10:36 AM
              0 responses
              13 views
              0 likes
              Last Post Touch-Ups  
              Started by geddyisodin, 04-25-2024, 05:20 AM
              11 responses
              63 views
              0 likes
              Last Post halgo_boulder  
              Working...
              X