Announcement

Collapse
No announcement yet.

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:

    https://ninjatrader.com/support/help...alues_that.htm

    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.
                https://ninjatrader.com/support/helpGuides/nt8/high.htm
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Tmaninc, Today, 03:05 AM
                0 responses
                10 views
                0 likes
                Last Post Tmaninc
                by Tmaninc
                 
                Started by stormcloudseven, Yesterday, 08:41 PM
                2 responses
                17 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by DavidTrades, Yesterday, 08:05 PM
                1 response
                16 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by memonolog, Today, 01:42 AM
                0 responses
                7 views
                0 likes
                Last Post memonolog  
                Started by hdge4u, Yesterday, 09:09 PM
                0 responses
                24 views
                0 likes
                Last Post hdge4u
                by hdge4u
                 
                Working...
                X