Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Printing by the tick with an indicator calculating OnBarClose

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

    Printing by the tick with an indicator calculating OnBarClose

    This indicator which calculates <OnBarClose> has a 'Print' statemen and left to it's own devices will print once per bar. It is included in my strategy which calculates <OnEachTick> so the indicator print out is on the tick. Is there any way to prevent this by the tick printoout?t

    #2
    Hello galsermil,

    Thanks for your post.

    You could consider creating a condition that checks IsFirstTickOfBar and calling your indicator or print statement in that condition so that it only occurs once at the beginning of a bar.

    See the help guide documentation below for more information and sample code.
    IsFirstTickOfBar: https://ninjatrader.com/support/help...ttickofbar.htm

    We also have this reference sample using IsFirstTickOfBar which you may find helpful: https://ninjatrader.com/support/help...either_cal.htm

    Let us know if we may further assist.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Brandon,

      For me the problem is that since I don't know what or where in the strategy it is taking control of the indicator, I don't know where to put the <IsFirstTickOfBar>. I already use <IsFirstTickOfBar>. in the strategy to push the entry until the Open of the next bar...

      Comment


        #4
        Hello galsermil,

        Thanks for your note.

        This would depend entirely on your use case and your strategy's logic. You could consider making a section of code for that purpose, but you could surround whatever code you need with that condition.

        If you are already calling IsFirstTickOfBar in your strategy, you could consider adding your print within that IsFirstTickOfBar condition check as a good place to start.

        Note that in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services in our support. This is so that we can maintain a high level of service for all of our clients as well as our partners.

        Let us know if we may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Brandon
          There seem to be two things that you do not understand, first, I have no idea why a strategy should be controlling the print function within an indicator and that is what I mean about not knowing when or where to put <IsFirstTickOfBar>, and second, I did not send this request to Platform Support, I sent it to the focus group which is supposed to have the purpose of helping us struggling novices through NT8 Script, so please don't give me that song and dance : "Note that in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services in our support. This is so that we can maintain a high level of service for all of our clients as well as our partners".

          Comment


            #6
            Hello galsermil,

            Thanks for your note.

            Please see the attached example scripts for how this could be accomplished.

            In the example indicator script, we assign the current Close price to a plot and print out the value of the plot.

            In the strategy, we check if (IsFirstTickOfBar) and call our Print statement to print out the indicator value once per bar.

            Note that when you run the strategy, you will see prints occurring OnEachTick vs once per bar when IsFirstTickOfBar is true.

            See the help guide documentation below for more information.
            IsFirstTickOfBar: https://ninjatrader.com/support/help...ttickofbar.htm

            Let us know if we may assist further.
            Attached Files
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment


              #7
              Brandon,

              There is something that I still do not understand and one new question. In your example you actually create a new instance of a 'Print' and with my indicator and strategy, I do not, it seems to be generated from within the original indicator and the frequency dictated by the calculation method of the strategy. How or why does a new 'Print' overcome the original 'Print' in the indicator?
              My new question, why do you create a new variable ' val' and never use it?

              Comment


                #8
                Hello galsermil,

                Thanks for your note.

                The print from the indicator comes when the indicator is referenced in the strategy. When we assign the indicator to a variable named "val", the print from the indicator occurs on each incoming tick since the strategy is running with Calculate.OnEachTick and the indicator is being referenced.

                If you want to limit how often the print comes you could either: 1. Remove the print. 2. Control how often the indicator is referenced in the strategy so the print is not seen as often. For example, if you comment out line 68 in the previously attached example script, you will see the print occur when IsFirstTickOfBar is true instead of for each incoming tick.

                If you have further questions, please modify the example script so that it demonstrates what you mean and attach it with your question.

                Let us know if we may assist further.

                <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                Comment


                  #9
                  Thank you. I will spend some time digging into your explanation.

                  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