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

Can a strategy using OnBarClose enter a long/short at the close price of Bar[0].

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

    Can a strategy using OnBarClose enter a long/short at the close price of Bar[0].

    Hi,

    I have strategies that use non time based intervals and the open price of the next bar following the the OnbarClose[0] can be a calculated rather then actual price.

    For the sake of trying to arrive at as an accurate a back test as possible it would be desirable to have the position be established at the close of bar[0].

    I didn't see anything that indicated that was possible but thought I would ask.

    Thank you very much.

    glen

    #2
    Sure, you can enter Short/Long order by using Close[0] value.

    Comment


      #3
      cincai,

      Thank you could you please give me and example of an EnterLong() function using Close[0]. Apologies but I see EnterLongLimit() EnterLongMIT() where the closing price could be specified but there is no guarantee of a fill. I want to enter at the Close[0] because for certain types of non price based charts the open of the next bar for unirenko for example is not an actual opening price and will inflate the profits in a back testing report. I'm trying to develop techniques that will insure to whatever extent possible the most accurate back test for non time interval chart types.

      Thank you

      Comment


        #4
        Next unirenko bar appears when market already traded 1 tick higher/lower than previous bar. So there is no guarantee that your market order at bar close will be filled. Filling orders with unirenko is one of the most challenging thing you can do with strategy analyzer. So many fake millioners on backtest results than can't make a dime with unirenko. My advance to you is don't waste your time. It's not gonna work. Especially if you're new to backtesting. Use time based charts, tick, volume anything but not unirenko.

        Comment


          #5
          Hi Leeroy_Jenkins,

          Thank your for taking the time to respond. I wish I were new to back testing. I've spent years trying to find something I can trade intraday with minimal draw downs and it's the most difficult things I've done in my life. If you can offer any suggestions as you are obviously an expert please let kne know how to get as accurate test as possible.

          I was asking about hot to even use the EnterLong() to attempt to execute on the close[0] and don't see how it's done with that function, do you have an example?

          Thanks for the "reality check" advice I agree Unirenko is one $OB of a chart type to get a reliable back test. The problem is I'm in a room where the guy who runs it absolutely make a killing, each and every day! And there is no B$ because he posts his entry at entry and exit at exit real time and fleshes his account ledger daily on his 1 lot account. We don't see his real 5+ lot account. The one lot which as you knw is either all in or all out is much more difficult to make money and he averages $2k a day trading, ES, CL and GC.

          When I hand test or trade these setups and they are not very complicated although take a few months to learn I know for an absolute fact they make money, not perfect but everyday a few setups show up in these markets that hopefully I can provide for my family after COVID trashed my IT consultant day job.

          So I'm stuck with doing everything I can to get a accurate Unirenko test. BTW if you want accurate back test on non time interval vote for future enhancement SFT-3979

          ********** Cast your Vote for system Enhancement SFT-3979 ********** If any NT customers are interested in an enhancement to a future release that would enable accurate back testing for non time based interval bar types, please cast your vote for enhancement SFT-3979, by replying to this post or opening another. This


          If you can recommend any general system suggestions on time, tick or volume without of course asking for the crown jewels but can point me in the fight direction please do.

          I would be more then happy to share the setups I've learned in the room with anyone as someone was generous to share them with me I believe in "doing the right thing".

          I was asking how to use the EnterLong() function to at least attempt to trade at the closing price and can't find a way to do that. If you can help I'd appreciate it.

          Finally I appreciate you taking the time to respond and wish you nothing but success in your trading ventures. If you ever want to take it offline or brainstorm please I'd be happy to hear from anyone.

          glen

          [email protected]

          Comment


            #6
            Hello demarcog,

            Thank you for the post.

            Just to add to Leeroy_Jenkins reply, one addition is that renko bars cannot be replicated accurately in a backtest due to their logic. In most cases to accurately test any renko bars type that would need to be done moving forward in playback or in realtime. The backtest can give a general estimate based on the hard OHLC values which the series has but would otherwise still contain differences based on how renkos work. If you are using a renko that was specifically designed for backtesting you could review that BarsType with the developer of that type to get more clear instructions on how they are using it to produce accurate results. It sounds like in this situation you would likely be best off running it forward in realtime like what you are comparing against, you will very unlikely be able to match the live tests from the other uses via backtest.

            For the EnterLong(), that would submit based on the bars prices but there is no overload to specify a price. I believe Leeroy_Jenkins was just saying that you could use a market type order for that use case. Leeroy_Jenkins could further clarify if I have misunderstood.

            Please let me know if I may be of additional assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hi Jesse,

              Thank you for that interesting and informative reply. I'm very interested and took a look at the Bar types code for a few non time based charts and it is fascinating. Presumably Playback must have either a different algorithm for building the charts that also processes tick data similar to how the chart is build in real time.

              Your suggestion of getting more insight from the developer into how the bar is build and if a version for back testing could be perhaps used when back testing, is a fantastic idea and may be the solution we are looking for. The bar type could be modified and used for back testing. The existing bar type for Heinken Ashi and Unirenko are very complex and obviously done by a highly skilled professional developer. Hats off to them.

              Would it be possible to pass on the request for assistance to the developer. I do realize how busy they and it does seems that many other customers have expressed interest and there is a SFT-3979 that looks to incorporate tick data with the Strategy Analyzer.

              Thank you again,

              glen

              Comment


                #8
                Hello demarcog,

                Right, the playback just uses real data that was recorded so its just using the existing mechanisms the platform already has for live data. Its simply playing that data or pumping it into the platform for the tools to utilize at a controlled speed.

                The main item that prevents a renko from working the same in a backtest is that renko bars on real-time data re-draw the open based on the direction of the bar. This cannot be simulated historically. Backtests use four, and only four data points: the open, high, low and close. Other means of backtesting, such as Market Replay/Play Back, can still yield appropriate results because the remove last bar logic can now work again so the renkos logic works completely.

                For the feature request you linked I just wanted to quickly note, that feature request is essentially the same as using the playback connection right now.

                That feature request is simply to include the analyzer in the tools which can be used with playback data. If we make a quick assumption on how that would work in contrast to playback data, it would need to play forward through the data at a increased speed. That would be the equivalent of applying a strategy to the control center and not having any charts open, then playing at max speed. The only gain from that feature request would likely be also using the optimizer. I just wanted to point out that you can do this type of test now by using playback so you wouldn't need to wait for the feature request if you wanted to test the script in this way. If that feature were implemented I would assume that some option would be added so you could pick playback data instead of historical but the test would still take generally the same amount of time because it has to play through that data.


                Please let me know if I may be of additional assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Hi Jesse,

                  Thank you for the response. Renko does have that unique quality of a redraw of past data based on more current data. Unirenko has other issues that's not one of them.

                  Thank you very much for the helpful and informative response.

                  glen

                  Comment


                    #10
                    What if a strategy evaluates only the High[1], High[0], Low[1], Low[0] of completed Unirenko bars? Does this bypass the artifical Offset opening issue?

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by hazylizard, Today, 08:38 AM
                    2 responses
                    8 views
                    0 likes
                    Last Post hazylizard  
                    Started by geddyisodin, Today, 05:20 AM
                    2 responses
                    17 views
                    0 likes
                    Last Post geddyisodin  
                    Started by Max238, Today, 01:28 AM
                    5 responses
                    47 views
                    0 likes
                    Last Post Max238
                    by Max238
                     
                    Started by giulyko00, Yesterday, 12:03 PM
                    3 responses
                    13 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by habeebft, Today, 07:27 AM
                    1 response
                    16 views
                    0 likes
                    Last Post NinjaTrader_ChristopherS  
                    Working...
                    X