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

Bar reference on renkos

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

    Bar reference on renkos

    I'm having difficulties using the recommended "CurrentBar - Bars.GetBar(Time)" to get barsAgo values.
    My problem happens when I code for time independent charts such as Renkos.
    When price moves really fast, the bars get indexed with the same Time which makes referencing them completely wrong.
    The following is an example of when three or more bars will have the exact same time but different bar index. When trying to get the barsAgo value I will get the first bar with that time instead of for example the third.

    Click image for larger version

Name:	BarReferenceIsWrong.png
Views:	109
Size:	21.2 KB
ID:	1229552

    I would really like some Best practice suggestions on how to solve this because it is causing both logic and drawing methods to be completely off.

    #2
    Hello Borgen,

    Thanks for your post.

    Renko bars are based on price movement and are not time-based bars which means that it is possible for multiple bars to have the same Time value if they closed within that time.

    You could consider saving the bar index (CurrentBar) to a variable when your condition becomes true, subtracting that value from CurrentBar to get the number of barsAgo, and using that value when calling your Draw method.

    For example, Draw.Dot(NinjaScriptBase owner, string tag, bool isAutoScale, int barsAgo, double y, Brush brush)

    Drawing: https://ninjatrader.com/support/help...t8/drawing.htm
    CurrentBar: https://ninjatrader.com/support/help...currentbar.htm

    Or, you could consider adding a time-based bar series to your script using AddDataSeries() and base your calculations off that added series.

    AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm
    Working with Multi-Timeframe/Multi-Instrument NinjaScripts: https://ninjatrader.com/support/help...nstruments.htm

    Let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your answer all though I should probably add that this is a Ninjascript exclusive problem. I code for clients in other languages with mt4/5 being the most common. This never happens there. Every bar is exclusive on time. Not Ninjatrader though.

      The problem here is that you have a platform where the recommended practice to reference bars through "CurrentBars-Bars.GetBar(time)" is faulty and can't be trusted when using different types of bars. That's a terrible code design. That shouldn't happen. Do you see how bad that is in a trading platform?

      The amount of extra code work around I have to do in Ninjascript just to work with time independent charts is ridiculous. I shouldn't have to do that just to work with renkos which is a very common bar type.

      But most importantly this means I would have to recommend clients to reconsider to choose renkos or other bars for their ideas on Ninjatrader. Which on your part means that clients might choose not to use Ninjatrader and go for a different platform.

      I doubt that this will ever get fixed unfortunately since it's based around how Ninjatrader references Bars. If it does though, an idea would be to add additional microseconds to the bars to make them more exclusive. That way an extra microsecond could be added to each renko bar per default. It is possible to fix this problem, if your developers wants to fix it that is.​
      Last edited by Borgen; 01-02-2023, 11:35 PM.

      Comment


        #4
        Hello Borgen,

        Thanks for your note.

        I have submitted your vote to an internal feature request for adding microseconds to Renko bar timestamps. This request is being tracked under the number SFT-3652.

        As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

        Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

        Please let us know if we may be of further assistance to you.​
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by terofs, Yesterday, 04:18 PM
        1 response
        21 views
        0 likes
        Last Post terofs
        by terofs
         
        Started by CommonWhale, Today, 09:55 AM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by Gerik, Today, 09:40 AM
        2 responses
        7 views
        0 likes
        Last Post Gerik
        by Gerik
         
        Started by RookieTrader, Today, 09:37 AM
        2 responses
        13 views
        0 likes
        Last Post RookieTrader  
        Started by alifarahani, Today, 09:40 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X