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

Calling CandleStick pattern name from an indicator

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

    Calling CandleStick pattern name from an indicator

    Hello,

    I downloaded this CandleStickPatternAll indicator: https://ninjatraderecosystem.com/use...kpatternall-2/

    and I tried calling patterns using this print: Print(Time[0] + " " + CandleStickPatternAll(Close, 4)[0]);

    But it only returns timestamp and 1 (when pattern is present) and 0 (when pattern is absent).

    How do I modify a code of an indicator, so it would return a pattern name instead of 1 or 0?

    #2
    Hello UltraNIX,

    Thank you for your post.

    What I would recommend in this case is to create a Series<T> variable to hold a string and then update that variable with the bar pattern name or an empty string if there's no particular pattern for a bar.

    Here's an example of exposing a variable that's not a plot's value:



    I'd keep the existing 0/1 functionality but just add the Series<T> to access the names from another script.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      I got error message:
      'NinjaTrader.NinjaScript.Indicators.CandleStickPat ternAll.CSPN1' is inaccessible due to its protection level

      I tried to use this print: Print(Time[0] + " " + CandleStickPatternAll(Close, 4).CSPN1[0]);

      Where CSPN1[0] is a series from CandleStickPatternAll. Indicator compiled fine, but strategy gave an error.

      Comment


        #4
        Hello UltraNIX,

        Thank you for your reply.

        Would you be able to post your current modified version of the code so I may test on my end? You can export it from Tools > Export > NinjaScript Add-on. Do not check the box to export as a compiled assembly or I will not be able to review the code. Please attach the resulting .Zip file to your reply.

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Here you go. I added "//" before Print in strategy for it to compile.
          Attached Files

          Comment


            #6
            Hello UltraNIX,

            Thank you for your reply.

            You haven't got an exposed property for your Series<T> in the indicator, so the strategy can't access it.

            You need to add something like this to the Properties region:

            [Browsable(false)]
            [XmlIgnore]
            public Series<string> cSPN1
            {
            get { return CSPN1; } // Allows our public cSPN1 Series<string> to access and expose our interal CSPN1 Series<string>
            }

            You could then access this in the strategy with:

            Print(Time[0] + " " + CandleStickPatternAll(Close, 4).cSPN1[0]);

            I've made the c in the exposed series lowercase to differentiate it from your internal CSPN1 series.

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Thanks, works like a charm. By the way, another candlestick-related question. How to make 'approximate estimation', like if high is within 3% range from previous high, then X, if not, then Y. I just want basic calculation process, which I could adapt to my own use.

              Comment


                #8
                Hello UltraNIX,

                The 'Select pattern' is a public property that does not change that can be returned from the script.

                Print(CandleStickPatternAll(Close, 4).Pattern);


                To find a percent of the high you can multiply the high by .03.

                High[0] * .03

                To get the high of the previous bar, use 1 as the barsAgo index.

                High[1] > High[0] - (High[0] * .03)

                Below is a link to the help guide on the High series.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by halgo_boulder, Today, 08:44 AM
                0 responses
                1 view
                0 likes
                Last Post halgo_boulder  
                Started by drewski1980, Today, 08:24 AM
                0 responses
                3 views
                0 likes
                Last Post drewski1980  
                Started by rdtdale, Yesterday, 01:02 PM
                2 responses
                17 views
                0 likes
                Last Post rdtdale
                by rdtdale
                 
                Started by TradeSaber, Today, 07:18 AM
                0 responses
                7 views
                0 likes
                Last Post TradeSaber  
                Started by PaulMohn, Today, 05:00 AM
                0 responses
                10 views
                0 likes
                Last Post PaulMohn  
                Working...
                X