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

heiken-ashi not correct

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

    heiken-ashi not correct

    Good day.
    theme: creating Ashi bars.
    I am writing in Java outside the ninja trader environment.
    but I use the broker's data downloaded from the ninja trader.
    the data is correct.
    I am using the formula from this post
    (Paul's answer is 03-25-2020 at 07:04 AM).
    https://ninjatrader.com/support/foru...n-ashi-candles
    and the code from the ninja trader editor.

    but my calculated data is not the same as the Ashi bars on the chart. high and low prices are the same. and open and close are not.
    1. when creating the first ashi bar, I take the data of the first regular bar.
    2. when creating the next Ashi bars, I calculate from the previous Ashi bar. Only for creating the Close ashi bar, I used the data of the current regular bar.

    3.after calculating open, close, high, low Ashi, I round them with my implementation of the RoundToTickSize() (NQ tick 0.25):
    return: price % 1 == 0 ? price : Math.round (price / .25) * .25;
    https://ninjatrader.com/support/help...toticksize.htm
    "Returns a value that is rounded up to the nearest valid value evenly divisible by the instrument's tick size".
    4. I expect the result with correct ashi bars after 540 5m ashi bars. but the open and close data are not correct, they are lower than what I see on the chart.

    tell me please, where am I wrong? well, except that I'm programming in java.
    Last edited by Danila; 08-12-2021, 06:21 AM.

    #2
    Hello Danila,

    Thanks for your post.

    The NinjaTrader Heiken-Ashi Barstype works well for historical data, but Tick Replay and real-time data are not traditional with a Heiken-Ashi study. This is because the Heiken-Ashi values are recirculated in the bar with each new tick.

    An indicator would take the bar values and then convert them to Heiken-Ashi values which are more traditional.

    You could find a Heiken-Ashi indicator in our NinjaTrader Ecosystem User App Share center linked below.

    NinjaTrader 8 natively provides Heiken Ashi as a bar type for most common bar types (minute, tick, volume, second, day, week, month, year). This Heiken Ashi indicator is provided for the Range, Renko and any custom bar types that may be added. The indicator performs in the same manner as the NinjaTrader 7 version. 4-27-18 […]

    Let us know if we may assist further.

    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      hi Brandon
      "This is because the Heiken-Ashi values are recirculated in the bar with each new tick."
      recycling is not important to me.
      cause I only use the data of the closed bar.
      I don't need real-time intermediate bars.
      i do so.
      1.the current bar has closed
      (the unfinished bar does not interest me).
      2. I took his data and created ashi bar.
      in any case, there will be a moment in time when each next bar will use the closed past ashi bar and the current closed regular bar
      or what is wrong with my reasoning?

      Comment


        #4
        Hello Danila,

        Thanks for your note.

        Please see the Heiken-Ashi 8 indicator from the User App Share center linked in my previous post to compare your calculated values with the traditional Heiken-Ashi study.

        The Heiken-Ashi 8 indicator shows how a traditional Heiken-Ashi study calculates values.

        Let us know if we may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Hi Brandon
          i saw this code.
          but what should I have paid attention to there? there is nothing new.
          your formula ashi and mine are the same.
          only you are using Calculate.OnEachTick;
          I use .onCloseBar (thereby removing recirculation)
          so please reply to my previous post (Today, 07:16 AM)

          Comment


            #6
            Hello Danila,

            Thanks for your note.

            The Heiken-Ashi 8 indicator is a traditional Heiken-Ashi study and does not recirculate. This indicator could be run OnEachTick or OnBarClose.

            That said, you would need to confirm that your input data is the same and use the Heiken-Ashi 8 indicator for your basis of comparison.

            Debugging prints should be added to make sure the data going in is the same. Also, you should use prints to confirm the output of your calculations is the same as what the indicator calculates.

            Note that NinjaTrader uses the C# programming language and we would not be able to assist with programming in Java.

            Let us know if we may assist further.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              hi Brandon
              Thanks for your reply. You gave a hint, but not an answer.
              I compared data from the indicator that you offered, my code, and ninjatrader chart data.
              1. the data from an indicator and my code are the same.
              2. the data of the chart ninjatrader is not the same as with the indicator and my code.
              3. the code of indicator hasn't the method RoundToTickSize(). but it is not important. it changes it.

              an example in pictures:
              Click image for larger version  Name:	ha8_1.png Views:	0 Size:	154.4 KB ID:	1167686

              do you have any thoughts on this?
              ps. i want to get data like ninjatrader chart, but not like the indicator
              Last edited by Danila; 08-12-2021, 12:34 PM.

              Comment


                #8
                Hello Danila,

                Thanks for your note.

                I would expect that the results would be the same if your code has the same input data as the Heiken-Ashi 8 indicator + the same code + the same settings.

                As you can see in the attached screenshot, the values printed from the Heiken-Ashi 8 indicator are the same as the values on the chart.

                Please confirm the following.

                Are you comparing only the Heiken-Ashi 8 indicator to your code?

                Is the data going into your code the same as the data going into the Heiken-Ashi 8 indicator?

                Please add prints that print out the data going into your code and compare those prints to the Heiken-Ashi 8 indicator. Then, provide a screenshot of the Output window showing that the data going into your code is the same as the data going into the Heiken-Ashi 8 indicator.

                Are the calculations in your code the same as the calculations being made in the Heiken-Ashi 8 indicator? Please provide a screenshot showing that the calculations in your script are the same as the Heiken-Ashi 8 indicator.

                Is the result the same between your code and the Heiken-Ashi 8 indicator using the same confirmed input data?

                If you find differences between the Heiken-Ashi 8 indicator and your indicator, print out the input data to ensure that it is correct and provide us with a screenshot showing that the input data is the same and the calculations are the same but you are getting different results.

                I look forward to assisting further.
                Attached Files
                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  hi Brandon
                  I can be seen not correctly explaining what I need.
                  I will try to answer your questions and clarify my question.
                  ************************************************** ***
                  for example, I took one day of : NQ 06-21 05/21/2021
                  build two charts in one window:
                  1. the first chart with OHLC and ashi indicator.(top chart)
                  2. the second chart Without an indicator, only using the tools for constructing Ashi bars from the platform.(bottom chart)
                  Click image for larger version

Name:	settingsCharts5mAndAshi5m.png
Views:	464
Size:	71.6 KB
ID:	1167761

                  Click image for larger version

Name:	settingsIndicator.png
Views:	443
Size:	111.8 KB
ID:	1167763

                  ************************************************** ***
                  1. I compare the data of the indicator (top chart), my code, and the data of Ashi chart.
                  (Ashi chart -> bottom chart was built Not by the indicator, but by the ninja trader platform.

                  2. the data source going into my code, indicator, and platform are identical. attach: 21052021_5m_OHLC_in.txt

                  3. Printouts of the data from my code and indicator are identical. attach 21052021_5mAshi_OHLC_outmycode.txt
                  i took data of bar 16:30

                  Click image for larger version

Name:	chartWithDataIndicatorAshi(top)_dataOfmyCode_andAshiPlatform(bottom).png
Views:	453
Size:	77.4 KB
ID:	1167768

                  As you can see in the picture, the output prints of my code and your indicator are the same.

                  The data (of your indicator == my code), but does not match the bottom Ashi chart that the platform has built.

                  And Big Question: is why the data of Ashi chart(bottom) and the top chart(indicator, my code) do not identical?
                  Attached Files

                  Comment


                    #10
                    Originally posted by NinjaTrader_BrandonH View Post
                    Hello Danila,

                    Thanks for your note.

                    I would expect that the results would be the same if your code has the same input data as the Heiken-Ashi 8 indicator + the same code + the same settings.

                    As you can see in the attached screenshot, the values printed from the Heiken-Ashi 8 indicator are the same as the values on the chart.

                    Please confirm the following.

                    Are you comparing only the Heiken-Ashi 8 indicator to your code?

                    Is the data going into your code the same as the data going into the Heiken-Ashi 8 indicator?

                    Please add prints that print out the data going into your code and compare those prints to the Heiken-Ashi 8 indicator. Then, provide a screenshot of the Output window showing that the data going into your code is the same as the data going into the Heiken-Ashi 8 indicator.

                    Are the calculations in your code the same as the calculations being made in the Heiken-Ashi 8 indicator? Please provide a screenshot showing that the calculations in your script are the same as the Heiken-Ashi 8 indicator.

                    Is the result the same between your code and the Heiken-Ashi 8 indicator using the same confirmed input data?

                    If you find differences between the Heiken-Ashi 8 indicator and your indicator, print out the input data to ensure that it is correct and provide us with a screenshot showing that the input data is the same and the calculations are the same but you are getting different results.

                    I look forward to assisting further.
                    I looked at your picture. here you have these two charts.
                    1. platform chart. 2.chart indicator. in one window. and they(bars) are different!
                    you yourself can see the difference. why did you ask for my data if you can already see that the data diverges ??

                    Comment


                      #11
                      Hello Danila,

                      Thanks for your note.

                      I understand that you are comparing the Heiken-Ashi indicator with the Heiken-Ashi BarsType.

                      It is expected that there will be differences between the indicator and the BarsType because these scripts are not the same.

                      The BarsType rounds values with developing bars in a non-traditional sense. The indicator is a more traditional Heiken-Ashi study and does not round values. The indicator values are developed from actual price levels and not re-circulated into the bar like the BarsType does.

                      We are recommending you compare an indicator with an indicator. Our HeikenAshi indicator from the User App Share should be used as the basis of comparison for your task.

                      We will need to be on the same page here in order to proceed.

                      Let us know if we may assist further.
                      Brandon H.NinjaTrader Customer Service

                      Comment


                        #12
                        hi Brandon
                        "The BarsType rounds values with developing bars in a non-traditional sense. The indicator is a more traditional Heiken-Ashi study and does not round values. The indicator values are developed from actual price levels and not re-circulated into the bar like the BarsType does. "

                        Sorry for being straightforward, but there is a lot of fog and some kind of mystery.
                        But it's not building a rocket for space.
                        Answer please:
                        1. after the closed bar BarsType(Ashi) can change its parameters (open, close ..)?
                        2. What is the BarsType(ashi) rounding formula for plotting ashi bars?
                        3. What do I need to change in your indicator so that the indicator shows the same values as your BarsType(ashi)?

                        Comment


                          #13
                          Hello Danila,

                          Thanks for your note.

                          The OHLC prices levels in a BarsType are made when the price levels in the bar are updated. Anything you give AddBar and UpdateBar in the BarsType is rounded to the nearest tick size using RoundToTickSize. AddBar closes a bar by signaling new bar is being developed.

                          AddBar: https://ninjatrader.com/support/help...nt8/addbar.htm
                          UpdateBar: https://ninjatrader.com/support/help.../updatebar.htm
                          RoundToTickSize: https://ninjatrader.com/support/help...toticksize.htm

                          Other than that, how the BarsType is calculated is in the BarsType script. Please see the Heiken-Ashi BarsType script in a New > NinjaScript Editor window.

                          You could create a copy of the Heiken-Ashi BarsType and add prints that print out what goes to AddBar and UpdateBar before those methods are called if you want to look closer into how the bars form.

                          To create a copy of the BarsType, open the Heiken-Ashi BarsType script in a NinjaScript Editor window, select 'Save as', name the copy of the script, and click OK.

                          Keep in mind when developing BarsTypes, bars get built into the cache, so the cache has to be cleared to have the BarsType build bars.

                          Let us know if we may assist further
                          Brandon H.NinjaTrader Customer Service

                          Comment


                            #14
                            hi Brandon

                            I think I understand that it will not work to recreate this type of bar.
                            since at each separate moment in time, they are updated when the price changes inside the unfinished bar(recirculation).
                            I was wrong, cause I didn't know the mechanism for creating this type of bar.
                            I thought that I can build them with history bars. but they are created at this point with floating data. which cannot be recreated.

                            Last chance and idea:
                            How do you think it is possible to recreate recirculation using historical ribbon prints?
                            can i download print ribbon data from ninja? If yes. then how to do it?

                            Comment


                              #15
                              Hello Danila,

                              Thanks for your note.

                              An indicator assigns plots from the values you give to each Values[][]. You are free to track any variables you want as you want and you can use those variables to assign your plot values.

                              Data is downloaded from the data provider you are connected to when a chart is made to request data, for example. Data can also be imported via text file as long is it follows our documented formats.

                              See this help guide page for more information: https://ninjatrader.com/support/help.../importing.htm

                              Let us know if we may assist further.
                              Brandon H.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by George21, Today, 10:07 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post George21  
                              Started by Stanfillirenfro, Today, 07:23 AM
                              8 responses
                              23 views
                              0 likes
                              Last Post Stanfillirenfro  
                              Started by DayTradingDEMON, Today, 09:28 AM
                              2 responses
                              16 views
                              0 likes
                              Last Post DayTradingDEMON  
                              Started by navyguy06, Today, 09:28 AM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              8 responses
                              32 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X