Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Making Close[0] == current price

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

    Making Close[0] == current price

    Let's say you want to enter a long the moment the current bar is one tick above the high of the last bar. So, if(Close[0] == High[1] + .25) //or 1 * TickSize. I have CalculateOnBarClose sent to false and am not using FirstTickOfBar. However, the strat still waits for the close of the current bar and then does the math, causing me to miss trades. How do I get it to enter the instant I get that one tick?

    Thanks,
    Dave

    #2
    Dave, please add prints to determine when exactly your created conditions evaluate to 'true' - with the OnBarUpdate() called for each tick you should be able to send the signal at the tick it triggers, is this a MultiSeries strategy?

    Comment


      #3
      Hey Bertrand,

      No sir on the multiseries. This is what I have:

      PHP Code:
      if ((entryOrder1 == null && EMA(20)[0] > EMA(50)[0] &&
      (Close[1] < Open[1] && Close[0] == High[1] + .25 ||    
      Close[2] < Open[2] && Close[0] == High[2] + .25 ||    
      Close[3] < Open[3] && Close[0] == High[3] + .25 ||
      Close[4] < Open[4] && Close[0] == High[4] + .25)))
      {
                                  entryOrder1 = EnterLong(DefaultQuantity, "OnePoint");
                                  DrawArrowUp("", true, 0, Low[0] - 12 * TickSize, Color.Blue);
                                  DrawTriangleUp("My triangle up" + CurrentBar, false, 0, Low[0] - 12 * TickSize, Color.Blue);
                                  PrintWithTimeStamp("Enter Long");
                                  longSent = false;
                              } 
      
      As you can see, I have plenty of confirmation that it only works on bar close. The idea is to go long once resistance (high of the last red bar from 1-4 bars ago) is broken - hence the "or" code above. Did I do something wrong?

      Thanks.

      Comment


        #4
        I would suggest you simplify your condition until the point where it takes the trade intrabar or you see prints for this happening - then you can add more and see where the logic breaks for achieving what you want - why not prepare for example a stopLimit order at this price in advance? Wouldn't this be simpler?

        Comment


          #5
          Well, the thing is that I used to have a strat that did what I want but I must have deleted it since. In fact, that's what led me to FirstTickOfBar as I wanted Close[0] to actually mean close of bar. So, since I know it's possible, I thought this would work. I'll break it down as you suggested but before I do, do you see anything inherently wrong with what I have?

          Comment


            #6
            Didn't see anything from a quick lookover Dave, would need to debug it as well to pinpoint where the logic breaks. I just feel the point in time where all your combined conditions trigger is just not what you expect.

            Comment


              #7
              dsraider,

              I have been able to do this in 6.5. I have not tested 7.

              The only way I have been able to get a strategy to execute orders in real time is by referencing only the bar series. Close, Open, High, Low.

              This means you may not reference any indicators!!!!

              I have also successfully used tick offsets for entry or target values

              It may be possible to reference indicators on a separate chart but on the chart where orders are placed, you cannot reference EMA like I see in one of your posts.

              Attached is a 6.5 sample strategy.

              Copy to strategy folder then open with strategy analyzer.

              Hope this helps,

              RJay

              Originally posted by dsraider View Post
              Let's say you want to enter a long the moment the current bar is one tick above the high of the last bar. So, if(Close[0] == High[1] + .25) //or 1 * TickSize. I have CalculateOnBarClose sent to false and am not using FirstTickOfBar. However, the strat still waits for the close of the current bar and then does the math, causing me to miss trades. How do I get it to enter the instant I get that one tick?

              Thanks,
              Dave
              Attached Files
              RJay
              NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

              Comment


                #8
                Bertrand - will do. Thanks for taking a look.

                rt - thanks for the .cs. Man oh man do things look better now that I have Visual Studio. I could have sworn I had other indicators in there as I never take trades without trend confirmation so if I figure out how I did it before, I'll post the code here.

                Dave

                Comment


                  #9
                  Fellas,

                  It turns out that one of my third-party indicators (which I didn't post here) doesn't like being set to current bar, for whatever reason. A quick change from [0] to [1] solved the problem and really doesn't affect my strategy, so I'm fine with it. I guess that's what I did in the past. Anyway, it works perfectly now. RJay, maybe you had the same issue?

                  Thanks,
                  Dave

                  Comment


                    #10
                    Maybe I was using a funky indicator too.
                    RJay
                    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    633 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    364 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    105 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    567 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    568 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X