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

Set Condition - Range of last bar?

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

    Set Condition - Range of last bar?

    Hello,

    I'm sure there is a very obvious answer to this but as a new user, I'm not sure what I need to do.

    In Strategy Builder, I just want to make a condition that refers back to the range of the previous bar. For example, "if the previous bar has a range greater than 20 ticks".
    I would think I would just want to write something like "if the high of the last bar is 20 ticks greater than the low of the last bar". But I can't figure how to write that in Strategy Builder.

    Would anyone mind explaining how I would create a condition like this?

    Thanks.

    #2
    Hello George21,
    You can use Indicator - > Range for range & refer snapshots for calculation. Hope it helps!

    Comment


      #3
      Hey,

      Thanks for the input there. That did answer my question, not sure why I couldn't figure that out myself, but I do appreciate you taking the time to show me.

      If you don't mind me asking another question...

      I was running a playback on Market Replay Data and my strategy seemed like it was executing as I would expect and then I hit this high volume spike at 3:50pm. My strategy executed like 400 trades in the 1 second bar...lol. Do you think this is just a glitch in the replay data or is it possible this strategy would actually do this in real time? $40,000 loss in 1 second is pretty impressive off 1 contract per trade.

      Click image for larger version

Name:	kill algo.png
Views:	208
Size:	99.2 KB
ID:	1147613

      Comment


        #4
        Hello George21,
        It seems you're using calculation method as OnEachTick, its generally advisable to use OnBarClose for avoiding such scenarios. You can also add a condition to enter trade once per bar as you're using 1 second time frame:
        Code:
        if (IsFirstTickOfBar)
        // Enter Long
        This condition will not be available in strategy builder due to its own limitations but you can unlock the strategy & add it.
        Hope it helps!
        Last edited by s.kinra; 03-21-2021, 04:07 AM.

        Comment


          #5
          Hi,

          Thanks for input. I tried a few different things. The weird part to me is that even when using 8 tick Renko bars with calculation OnBarClose, it over trades on that same volume spike bar. I guess I'll have manually enter the condition (IsFirstTickOfBar) like you suggested. Just seems like it's breaking the logic when it overtrades like this.Click image for larger version

Name:	renko2.png
Views:	195
Size:	122.0 KB
ID:	1147712

          Comment


            #6
            Can you share your strategy .cs file, so I can have a look into it.

            Comment


              #7
              Sure, nothing too special really. I've got some ideas for something more complicated but at this point I'm just trying to get 1 condition at a time to do what I think it should.

              Thanks for your time.
              Attached Files

              Comment


                #8
                Hello,
                I couldn't notice a single bar with multiple orders, I tested it with past 1 year data & new orders are also working fine. Its working as expected. You can try to change your account / connection to see if it makes any difference. Keeping things simple & clear is always good to start with.

                Comment


                  #9
                  Hello George21,

                  One thing to keep in mind is that you would need to change the Calculate setting for a configured strategy instance in the strategy parameters for that instance.

                  The Defaults are only pulled for new instances. Meaning if you change the Calculate setting in the Strategy Builder, this will not take affect on any configured instances. You would need to remove and re-add the instance to pull defaults for a new instance.

                  I would not expect the logic to be run multiple times on the same bar if the Calculate setting is OnBarClose in the Strategies window in the configured strategy parameters.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by s.kinra View Post
                    Hello,
                    I couldn't notice a single bar with multiple orders, I tested it with past 1 year data & new orders are also working fine. Its working as expected. You can try to change your account / connection to see if it makes any difference. Keeping things simple & clear is always good to start with.
                    Is that past year of data you tested with from your personal recording over the last year, or is there other ways of obtaining historical data like that?

                    I'm running the strat now on a live Rithmic feed and I haven't seen the multiple orders on a single bar yet. Makes me wonder if there's an issue with how my system recorded the data.

                    Comment


                      #11
                      quite possible data is the issue, I download data on daily basis.

                      Comment


                        #12
                        Originally posted by s.kinra View Post
                        quite possible data is the issue, I download data on daily basis.
                        Do you know if there is a difference in the nature or quality of the data when you download MarketReplay data from NT server at EOD compared to recording the live data yourself with the "market record" feature?

                        Comment


                          #13
                          Hello George21,

                          The download from NinjaTrader will be a solid recording, and this is recorded from Continuum.

                          Recording on your end will only be while connected and while a chart or other subscriber is receiving data, which can lead to gaps and missing data if NinjaTrader is not allowed to collect data 24/7 (or while the market is open).
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_ChelseaB View Post
                            Hello George21,

                            The download from NinjaTrader will be a solid recording, and this is recorded from Continuum.

                            Recording on your end will only be while connected and while a chart or other subscriber is receiving data, which can lead to gaps and missing data if NinjaTrader is not allowed to collect data 24/7 (or while the market is open).
                            Hi,

                            Thanks for this reply. Does this data from continuum have all the ask/bid data for strategies that calculate on the tick and conditions that execute off the current ask/bid?

                            Comment


                              #15
                              Hello George21,

                              Yes, the MarketReplay data does contain the ask and bid.

                              Give it a try. Open a chart to a bid or ask tick series and run the playback.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              40 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Today, 08:51 AM
                              2 responses
                              16 views
                              0 likes
                              Last Post bill2023  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              167 responses
                              2,260 views
                              0 likes
                              Last Post jeronymite  
                              Started by warreng86, 11-10-2020, 02:04 PM
                              7 responses
                              1,362 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Perr0Grande, Today, 08:16 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post Perr0Grande  
                              Working...
                              X