Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Batch Test candlestick patterns from indicator

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

    Batch Test candlestick patterns from indicator

    When I open indicator "CandleStickPattern", I see public enum ChartPattern and there each pattern has it's own number from 0 to 24.

    How can I use it within the strategy, so I could create int PatternNumber and use it in backtest (0;24;1) and each of 25 backtested number would correspond to particulart pattern?

    As it is based from Default NinjaTrader indicator, I expect a code example here. Thank you in advance.


    #2
    Hello UltraNIX,

    Thank you for your note.

    Yes, you can create an int input that can be optimizable and get the candle pattern associated with that int and use it to call the CandlestickPattern indicator by casting it as the enum. I've attached a simple example script that is optimizable.

    Please let us know if we may be of further assistance to you.
    Attached Files

    Comment


      #3
      Originally posted by NinjaTrader_Kate View Post
      Hello UltraNIX,

      Thank you for your note.

      Yes, you can create an int input that can be optimizable and get the candle pattern associated with that int and use it to call the CandlestickPattern indicator by casting it as the enum. I've attached a simple example script that is optimizable.

      Please let us know if we may be of further assistance to you.
      Thank you for example file.

      I have few questions for clarification.

      1) "Cpattern" is used in State.DataLoaded:
      Code:
       ChartPattern Cpattern = (ChartPattern)CandlestickPatternNumber;
      Pattern = CandlestickPattern(Cpattern, TrendStrength);
      However, I cannot find anything in @CandlestickPattern.cs, so what does it refer to?

      2) This line:
      Code:
       ChartPattern Cpattern = (ChartPattern)CandlestickPatternNumber;
      If I understand it correctly, it takes public enum ChartPattern from @CandlestickPattern.cs, however, I asked previously, what that line of code "Cpattern" defines.

      3)
      Code:
      (ChartPattern)CandlestickPatternNumber
      This, if I understand correctly,
      - (ChartPattern) refers to the same public enum from @CandlestickPattern.cs
      - CandlestickPatternNumber just uses the integer that is next to ever pattern?

      Why I ask all this? I also use bar patterns, like:
      Code:
      public enum ChartPattern
      {
      OutsideBar = 0,
      InsideBar = 1,
      RegularBar = 2,
      }
      As @CandlestickPattern.cs is rather a complicated indicator for me, where should I place rules for OutsideBar/InsideBar/RegularBar, so I could use it in strategies in similar fashion, like with Candlesticks and batch optimize it using integer, instead of just creating rules and test one by one?

      There are 124 bar types (instead of 3 shown here in enum), but I simply want to understand the concept and then apply to the remaining patterns.

      Thank you in advance.

      Comment


        #4
        Hello UltraNIX,

        Thank you for your reply.


        ChartPattern Cpattern = (ChartPattern)CandlestickPatternNumber;

        Basically, this takes the value from the user input and casts it as the ChartPattern associated with that numeric value and saves that to a ChartPattern variable called Cpattern which is then used to call the indicator - it's in reference to the ChartPattern enum in the CandlestickPattern indicator.

        You would need to name your new enum something other than ChartPattern since a public enum by that name already exists in the CandlestickPattern indicator:

        public enum BarPattern
        {
        OutsideBar = 0,
        InsideBar = 1,
        RegularBar = 2,
        }

        Once you have that in a script, you could create a user input in your script and use the same approach to refer to that enum via the numeric value:

        // note that BarPatternNumber would be a user input

        BarPattern Bpattern = (BarPattern)BarPatternNumber;

        if (Bpattern == BarPattern.InsideBar)
        {
        //Do something
        }

        Please let us know if we may be of further assistance to you.

        Comment


          #5
          And what code needs to be in the indicator script, so that it would 'appear' correctly?

          Comment


            #6
            Hello UltraNIX,

            Thank you for your reply.

            I'm not sure what you mean by "what code needs to be in the indicator script, so that it would 'appear' correctly" - you simply need to create a user input just as you would with any input, have your Enum in a script (not within the actual indicator class but outside it, like in the Candlestick Pattern indicator, and then you can refer to the enum from that indicator or any other in the same way by casting the input's value as the Enum value.

            Please let us know if we may be of further assistance to you.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            38 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            124 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            64 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            41 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X