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

Displaying text in a custom BarType

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

    Displaying text in a custom BarType

    Dear team,
    I'm having trouble trying to display some text in my custom bar type chart.
    I understand that Draw.Text won't work in barTypes, so we have to use the SharpDX tools.
    I'd like to stick to using the BarTypes to display the text (rather than Indicators, if possible).

    But, whatever I try to implement won't compile.
    I've tried following the text rendering comments at:

    with no luck so far.

    Could anyone post a simple 'Hello world' Ninjascript version to display a simple line of text using SharpDX from within a custom barsType please ?

    Many thanks

    #2
    Hi Louis335, thanks for your post.

    We provide the SampleCustomRender indicator script as a reference for common use cases of SharpDX including text rendering. This can be found in the Indicators folder of the NinjaScript Editor. See sections 1.6 - Simple Text Rendering and 1.7 - Advanced Text Rendering.

    If you have any questions on this material please let me know.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chris,
      Great, that works fine, but It's not clear to me how to port that exact same functionality over to a BarType class.
      I have created a new BarType, and would like to copy, as closely as possible, the SampleCusomRender indicator code into it as a starting point.
      Any pointers on how to do this much appreciated.

      Comment


        #4
        Hi Louis335, thanks for the follow up.

        The ChartStyle is actually what overrides the OnRender method. So first you would need to define how the bar should be built in the BarsType then apply a custom chart style to the bar type. See all of the default chart styles in the ChartStyles folder.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Ah, ok, thanks, that works.
          One question on data visibility.
          If I'm creating new data from within my custom BarTypes, say a noise factor at a given point in the bars, can this data be made visible from outside the custom Bar Type that I have created ?
          and can it be made visible to my new ChartStyle, for on chart display for example ?

          Comment


            #6
            Hello Louis335,

            Thank you for your follow up question.


            I want to mention three specific notes here on this approach:
            • BarsTypes only define set value types. There is no means to add an additional value type such as a value to pull or indicate something like a "noise factor". You can take a look at the value types that can be pulled from a bar at the following link: https://ninjatrader.com/support/helpGuides/nt8/bars.htm
            • BarsTypes are designed to set the Open, High, Low, Close, Volume, Time, Bid and Ask. They are not designed to create or contain custom values.
            • ChartStyles are designed to take the values of BarsTypes and display them visually in different manners.

            Based on your intended design as detailed in this thread I would recommend building an Indicator.
            • Indicators are designed to create and contain custom values.
            • Indicators can add visual elements to the chart with great versatility.

            A great example of an indicator that alters the visuals of bars that would be helpful in your design is the Heiken Ashi 8 indicator built by my colleague Paul Hunt. This is essentially the same thing as the Heiken Ashi BarsType but built as an indicator instead.
            Please let me know if you have any questions.

            Comment


              #7
              Thanks Patrick,
              that's quite an insightful reply, many thanks.
              (PS. couldn't get the HeikenAshi 8 Indicator to download (think the page is not found), is there another link, or could you send the file please ?
              Best,
              Louis

              Comment


                #8
                Hi Louis335, thanks for the follow-up.

                Here is the link again:
                https://ninjatraderecosystem.com/use...heiken-ashi-8/

                Make sure to click the hyperlink and not copy/paste the string above,the forum shortens URLs.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you for your help on this.

                  Comment


                    #10
                    With some creative hacking, you can create custom values in your BarsType script, and store them in the BarsPeriod.BarsPeriodTypeName property of the BarsType, then access the name property from the indicator, and extract the custom values / properties, using split, etc.
                    Last edited by balltrader; 07-26-2023, 02:35 PM.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Segwin, 05-07-2018, 02:15 PM
                    14 responses
                    1,788 views
                    0 likes
                    Last Post aligator  
                    Started by Jimmyk, 01-26-2018, 05:19 AM
                    6 responses
                    837 views
                    0 likes
                    Last Post emuns
                    by emuns
                     
                    Started by jxs_xrj, 01-12-2020, 09:49 AM
                    6 responses
                    3,292 views
                    1 like
                    Last Post jgualdronc  
                    Started by Touch-Ups, Today, 10:36 AM
                    0 responses
                    12 views
                    0 likes
                    Last Post Touch-Ups  
                    Started by geddyisodin, 04-25-2024, 05:20 AM
                    11 responses
                    62 views
                    0 likes
                    Last Post halgo_boulder  
                    Working...
                    X