Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entry on open of next bar

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

    Entry on open of next bar

    Can someone give me an alternative to using <IsFirsttTickOfBar>to enter a trade at the open of the next bar?

    #2
    Hello galsermil,

    Thank you for your post.

    IsFirstTickOfBar would be what would be necessary to use if you want to submit orders on the open of a bar.

    I've worked with you previously on this topic. If you would like to move forward, please provide a working example script illustrating what isn't working for you.

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Kate,

      I am going to include the .cs file again since my script is not very long. You told me that my 2 print statements would print the same number but when I allowed the CurrentBars[0] print on every tick, the CurrentBars[0] after the <IsFirst.> was one larger. I then tried to limit the print of one CurrentBars[0] by inserting an int variable Num and advancing the value after the print and then resetting it to -0- inside the <IsFirst> statement. When I do all this, the Bar numbers are the same inside and out and the entry orders do not execute. I believe that I am capturing the two signals on the current bar and what I want to do is enter an order at the open of the next bar when the two signals != 0. I am also trying to qualify a short or long entry based upon whether the bar with the signals are up or down where if up the entry would be short and down, the entry would e long
      Attached Files

      Comment


        #4
        Kate, I want to add a note. The CurrentBar[0] inside the <IsFirst> is printing ahead of the one outside therefore I can understand the Bar numbers being the same. I had assumed they would print in order of appearance.

        Comment


          #5
          Kate, another note. I think the the entries are not be executed because some way or another I believe that I am pushing the CurrentBar[0] forward so that the signals are back to-0- and no eligible for an order entry.

          Comment


            #6
            Hello galsermil,

            Thank you for your replies.

            I've made a simple example strategy that may help to illustrate entering an order on the first tick of a new bar based on two signals being true on the bar that just closed. This example will only run on real time data, as over historical data a strategy can only run OnBarClose and IsFirstTickOfBar will always return true on historical data.

            I would recommend testing on a 1 minute candlestick chart on either real time data or in Playback on Market Replay data, and you can view the prints it makes in the Output window.

            Please let us know if we may be of further assistance to you.
            Attached Files

            Comment


              #7
              Kate,

              I have three questions concerning the example that you sent me. First, where does one learn of a fact like the <IsFirstTickOfBar> will always be true with historical data? To my knowledge there is no such wisdom in the Users Guide. Second, I notice that you inserted your <if signal Condition> after your <IsFirstTickOfBarCondition> and I did a like thing in my script but what I would like to know is there a best practices on such placements that the more general should go first or some such or does it matter? Third, I assume that the following statement was inserted for illustration: only: Print(String.Format("CurrentBar: {0} | IsFirstTickOfBar: {1}", CurrentBar, IsFirstTickOfBar))?

              Thank you

              Last edited by galsermil; 03-04-2022, 06:18 PM.

              Comment


                #8
                Kate,

                I have three questions concerning the example that you sent me. First, where does one learn of a fact like the <IsFirstTickOfBar> will always be true with historical data? To my knowledge there is no such wisdom in the Users Guide. Second, I notice that you inserted your <if signal Condition> after your <IsFirstTickOfBarCondition> and I did a like thing in my script but what I would like to know is there a best practices on such placements that the more general should go first or some such or does it matter? Third, I assume that the following statement was inserted for illustration: only: Print(String.Format("CurrentBar: {0} | IsFirstTickOfBar: {1}", CurrentBar, IsFirstTickOfBar))?

                Thank you

                Comment


                  #9
                  Hello galsermil,

                  Thank you for your reply.

                  This is touched on in the help guide when it states "This property is only of value in scripts that run tick by tick which is when the Calculate property is set to Calculate.OnEachTick or Calculate.OnPriceChange." - it's not useful for running OnBarClose because it will always return true in that scenario.

                  As far as the order of the conditions, in this case the order doesn't really matter, you could even combine those conditions into a single if statement if you like. I've just done it like this so what's occurring in the script is as clear and easy to understand as possible.

                  And yes, the print you mentioned is to illustrate that when on real time data, the first tick of the bar causes IsFirstTickOfBar to return true.

                  Please let us know if we may be of further assistance to you.

                  Comment


                    #10
                    Kate,

                    I don't know how you always get stuck with me but thank you. I am almost finished with my little project and your example sent me on my way.

                    Again, many thanks.

                    Comment


                      #11
                      Kate,

                      I have returned to you because I am still struggling with <IsFirstTickOfBar>. I am going to include several pictures:First is my code and I have one principal question, can I group the <if statement the way I have with(XXX[1] &&( YYY[1] || YYY{0])). Don't bother with the punctuation:https://www.screencast.com/t/Td90WXEneZ. The second item on this picture is the Print line which ties to the next picture:https://www.screencast.com/t/MEsn4rwbkfwk. This is the output. First, you will notice on the chart picture that I have the OBOS on two bars but in the output there is only one signal. The MacDiver signal in the output is on the next bar but it is coming out as {1] and not [0]. Last but not least, notice the CurrentBars numbers, there are lots of repeated numbers and there are skips. I got no entry simply because I never had the signals together. Hope you can help me.

                      Comment


                        #12
                        Kate,https://www.screencast.com/t/u4NXzgALnpSb
                        I am not sure if I include this picture which goes with the rest:

                        Comment


                          #13
                          Hello galsermil,

                          Thank you for your replies.

                          I have moved your second response from another unrelated thread as it appears it goes on this thread. Please be sure to double check you're on the correct topic prior to posting.

                          First, yes, you can group conditions within your if statements within parenthesis and mix &amp;&amp; and || in that manner, that's fine to do.

                          As far as your issue with your script, I'm a little confused about what exactly is the expected behavior - can you supply a working example script that demonstrates with further detail regarding the intended behavior?

                          Thanks in advance; I look forward to assisting you further.

                          Comment


                            #14
                            Kate,

                            I apologize about the wrong thread but you are simply gong to have to write it off to ignorance. I don't even know what a thread is and I certainly do not know how to move around in this Focus format.
                            As regards the expected behavior, every indicator puts a Drawing object on the screen when the conditions for that indicator is satisfied. Each indicator creates a signal when the Draw Object is created and what I am trying to do is have my strategy pick up those signals as rapidly as possible and when I get a concurrence of five signals on the same bar I enter on the open of the next bar either long or short depending on the direction of the bar where the signals were found. The entry is always opposite since all of these signals are exhaustion signals. .There is one slight variation and that is when a MacDiver signal is on the current bar and the other four were present on the previous bar and I follow the same rules. Since I must have the signals appear on the same bar, I must have a signal every time that they appear on the screen regardless of how many successive bars they appear on. That was my problem with OBOS in the image that I sent you. In that case, I got no signal the first day, got one the second day and what was not on your picture, I got no signal the third day. When I sent you the pictures, I had reproduced OBOS in the Strategy rather than pick up a signal from the indicator as the indicator is merely paint the bar outline Magenta when RSI is above 75 and paint the outline Green when RSI is below 25. I discovered this morning at 4AM, MST that the parameters were different for RSI in the Indicator and in the strategy but that did not fix my problem so I restructured the indicator to produce a signal and the Strategy to intercept that signal. That still has not solved my problem as the indicator is putting out a signal only on the first day. I am not expecting anything from you as regards this OBOS problem unless you know something that is commonly the problem when signals will not follow through. You have answered my most significant question about grouping conditions. I would like to know why the Bar numbers were jumping around inside <IsFirstTickOfBar>, if you have an answer. Thank you for your help.

                            Comment


                              #15
                              Hello galsermil,

                              Thank you for your reply.

                              If an indicator is only signalling once and then not repeating as you would expect, I would suggest adding prints of the values it is using to see if the conditions for the signal within the indicator are becoming true or not as you think they should be.

                              As far as bar numbers "Jumping Around" when using IsFirstTickOfBar, the most commonly seen reason for this is that there are multiple data series in the script and the print isn't specific to one of those series. Can you confirm if you have any secondary data series added with AddDataSeries in the script? Can you give a simple example script that demonstrates the issue?

                              Thanks in advance; I look forward to assisting you further.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Today, 05:17 AM
                              0 responses
                              53 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              130 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              70 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              44 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              49 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X