Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator modification for Strategy Builder integration

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

    Indicator modification for Strategy Builder integration

    Hello guys.
    Thanks to the support team for helping us every time we need.

    I found an Indicator that is not so good, but basically is doing what it is pretending to do.
    I wish to include it in a strategy however, in it current state it is not suitable for doing this. I need to do some modifications on the code, so that the values of it are readable to the Strategy Builder.

    Basically, the indicator is related to the Initial Balance. Every day session it measures the high and the low of the first 1 hour of trading activity.

    I know that I need to include in the "#region Properties" Series<double> to make it accessible for the Strategy Builder. I did different changes because I had different errors, but finally I succeeded to run it on strategy. However, after running the Playback and test it, I got an error message like:

    "Strategy "OpenRangeStrategy": Error on calling 'OnBarUpdate' method on bar 0: Object reference not set to an instance of an object."

    I apply attachments to the original code, and the modified version of the indicator, and the strategy that I am trying to incorporate it in.

    If anyone have any ideas, please share!

    Best wishes.​
    Attached Files

    #2
    Hello nrgful,

    The SessionOpeningRange indicator should be able to be used in the builder, that has two plots which expose prices. This would not be able to be used historically due to its use of OnMarketData. You would need to use tick replay to use that indicator.



    Comment


      #3
      Could you please be more detailed. I have SessionOpeningRange in the builder, but there is no option to choose which High or Low of the range. And if I need to compare the highs and lows of two range, it is not possible to do that in the original version. I wanted to modify it in a way that is giving me a chance to compare the high and lows of the initial balance of two consecutive days for example. That's why I needed to do some modifications, but unsuccessfully. With the changes I made I had some progress, but not what I needed to be.

      What are the possible changes that I need to do, to receive the described behaviour?

      Best wishes.

      Comment


        #4
        Hello nrgful,

        In order to use that indicator with the strategy it can only be used in realtime, your strategy is not checking if the bar is realtime which is the reason for the error. You can use tick replay to simulate the OnMarketData override historically which would be required to see that work with the strategy how you have used it.

        You can enable tick replay in the options menu: https://ninjatrader.com/support/help...marketdata.htm

        You then also need to enable it in the chart or tool where the strategy is being used.

        Comment


          #5
          Hello, Thank you again for your support.

          But I test the strategy live - and there is the same error again. I had the Tick Replay -> ON before I wrote you. I restarted them - but the result is the same.

          Any other suggestions?

          Thank you in advance
          Best wishes

          Comment


            #6
            Hello nrgful,

            I tried the script on my en and it works as long as i turn on tick replay. One item I did note is that you have incorrectly used the plots with your modification.

            The way the original was made uses a double to store data before plotting it, you instead used a Series<double> which is not the same. Your variables should look like the following.

            public double ibHigh;
            public double ibLow;

            In OnBarUpdate you would have to set the plots like the following:

            Values[0][1] = orHigh;
            Values[1][1] = orLow;
            Values[2][1] = orHigh;
            Values[3][1] = orHigh;

            The variables which are being set to the plot would need updated how you see fit. The variables that you made you will also need to set to whatever values you intended.

            ​​​

            Comment


              #7
              Hello Jesse,

              I did not understand your last sentence: "The variables which are being set to the plot would need updated how you see fit. The variables that you made you will also need to set to whatever values you intended."

              And what about the
              # region Properties ???

              [XmlIgnore]
              [Browsable(false)]
              public double IBHigh {
              get
              {
              return Values[2];
              }
              }
              [XmlIgnore]
              [Browsable(false)]
              public double IBLow {
              get
              {
              return Values[3];
              }
              }

              If I set the ​

              public double ibHigh;
              public double ibLow;

              as you told me, then the code cannot be compiled.

              [XmlIgnore]
              [Browsable(false)]
              public double IBLow { <<<---- should be Series<double>
              get
              {
              return Values[3];
              }
              }

              Coudl you please show me your working version?

              Thank you in advance
              Best wishes​​

              Comment


                #8
                Hello nrgful,

                In your script you are setting the same variables to the new variables you made, you would have to modify your OnBarUpdate logic to set the correct values to those variables. The correct values are whatever modification you had intended to do.

                You already have these two lines:

                Values[0][1] = orHigh;
                Values[1][1] = orLow;​

                You will have to add two more lines to set the new plots you added

                Values[2][1] = orHigh;
                Values[3][1] = orHigh;​

                The values you set are up to you but it needs to be done in this way to set the plots.

                Regarding the public properties, you can revert back to the version you had uploaded to get rid of the compile errors, that script compiled successfully.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                66 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                141 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                76 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                47 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                51 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X