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

Need help with a few lines of NS code

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

    Need help with a few lines of NS code

    Hello:

    I would like some assistance parsing a string . The following code:

    barTypeName = Bars.BarsType.Period.ToString();

    returns

    SiBTRenko B:12 T:1 R:17

    Can someone please help with the code to extract the values of "B:" and "R:" above and covert them to an integer,

    or,

    if they can be directly acquired from the Bars object or class, whatever it is, (also as integers) that would be fine too.

    Much appreciated, and thank you

    #2
    Hello Cheech,

    Thank you for your post.

    You would instead use BarsPeriod.Value. Please visit the following link for more details: https://ninjatrader.com/support/help...barsperiod.htm

    Please let me know if you have any questions.

    Comment


      #3
      Hi Patrick:

      Thank you for your response.

      I looked at that before posting (but didn't try it) and according to the write up the BarsPeriod.Value only returns the brick size which is OK for the NT Renko bar. However, other Renko bars have more parameters which is why I though I would need to parse from the string text. There is a Value2 but only for Point and Figure bars. Just in case one of the other parameters is returned in Value2 even though this is a Renko bar, which one? And, is there a way of getting the 3rd?
      Last edited by Cheech; 11-21-2017, 09:32 AM.

      Comment


        #4
        Hello Cheech,

        Thank you for your response.

        Any custom bars types that may have additional items would assign their values to Value or Value2. If more parameters are needed and not listed at the following link then you can parse as you initially intended: https://ninjatrader.com/support/help...barsperiod.htm

        You can look into parsing at the following link: https://docs.microsoft.com/en-us/dot...g-string-split

        For converting a string to a number please visit the following link: https://docs.microsoft.com/en-us/dot...ng-to-a-number

        Please let me know if you have any questions.

        Comment


          #5
          Well, it seems like clicking on the first link led to some interesting events.


          The documentation at that location describes using Split to parse out characters as defined by delimiters. Because the documentation is for a language that is written for people whose brains are wired differently than mine and is also document by people whose brains are wired the same way, I needed to resort to copying the code in the example as closely as possible.


          Well based on the compile errors it appears that for some reason a Char is different than a String even though in my book a String is just a sequence of Chars stuck together, apparently not. After double checking the copied code and not to be discouraged by this set back I resorted to using the wonderful Google search engine to find sites where we mere mortals go to connect with the C# programming gods for advice and counsel. Well to my surprise another moral had the exact same error using the Split which was a slight relief that it wasn’t just me. In this case it appears that theses gods are not in complete agreement on what is the best way to parse information from a string, with several of them offering a different ways with a completely obscure reason for doing so.


          Finally a god of gods appeared with a tool which is some sort of relative expression builder which if properly fed the correct ubiquitous symbols encapsulated (wow, I used a word from this language (probably incorrectly) that all of these uniquely wired brains speak) in another set of ubiquitous symbols it will return the desired results. Well maybe and maybe not, depending.


          At this point I am wondering what an old dog like me (and I really mean “old”) is doing playing in a park with mostly young dogs that enjoy nipping at my tail while showing me around their playground. I hadn’t realized how easily it is to fall into a rabbit hole while trying to do some seemingly easy things using this language for which my brain is not pre-wired. And that was only the first link.


          Oh well, right now on to bigger and better things, a glass of wine and a comic book, both of which I can easily handle. We'll see what tomorrow brings.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by TraderBCL, Today, 04:38 AM
          1 response
          5 views
          0 likes
          Last Post bltdavid  
          Started by martin70, 03-24-2023, 04:58 AM
          14 responses
          105 views
          0 likes
          Last Post martin70  
          Started by Radano, 06-10-2021, 01:40 AM
          19 responses
          606 views
          0 likes
          Last Post Radano
          by Radano
           
          Started by KenneGaray, Today, 03:48 AM
          0 responses
          4 views
          0 likes
          Last Post KenneGaray  
          Started by thanajo, 05-04-2021, 02:11 AM
          4 responses
          471 views
          0 likes
          Last Post tradingnasdaqprueba  
          Working...
          X