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

OnEachTick and OnBarClose

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

    OnEachTick and OnBarClose

    I have a function in my strategy that depends on OnBarClose calculation to draw an object but I have other functions inside OnBarUpdate() that need OnEachTick calculation. Is this possible?

    #2
    Hello TraderMatt83,

    Thank you for your post.

    Yes, this is possible. You would need to set the strategy to calculate On Each Tick, and then within your logic for anything that requires updates On Bar Close, you can add a check to see if IsFirstTickOfBar is true. This is because a bar's close is determined by the first tick of a new bar forming. Here is the help guide page about IsFirstTickOfBar:


    Additionally, we have a reference sample that demonstrates how to separate logic to calculate either on each tick or on bar close:


    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      This will definitely work. Thank you!

      Comment


        #4
        Emily,

        I finally got this to work except not sure how to fix my issue where my trade is no longer taking the trade if the previous closing bar is above a range. This function below determines whether to go long if the previous candle close is above the range high but it appears to be taking the trade below the range high. And I know the range high is correct because I have it painted. Yet the entry always happens if the current candle hits the range high. Thoughts?

        private bool entryLongCheck()
        {
        return Close[1] > rangeHigh && Close[2] <= rangeHigh && High[0] > High[1] && CurrentBar - lastTradeBarLong > 2 && Close[0] > rangeLow;
        }​

        Comment


          #5
          Emily,

          I finally got this to work except not sure how to fix my issue where my trade is no longer taking the trade if the previous closing bar is above a range. This function below determines whether to go long if the previous candle close is above the range high but it appears to be taking the trade below the range high. And I know the range high is correct because I have it painted. Yet the entry always happens if the current candle hits the range high. Thoughts?

          private bool entryLongCheck()
          {
          return Close[1] > rangeHigh && Close[2] <= rangeHigh && High[0] > High[1] && CurrentBar - lastTradeBarLong > 2 && Close[0] > rangeLow;
          }​

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,406 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          98 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          8 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          160 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          9 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X