Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can't pass BoolSeries variables in Indicator to Strategy

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

    Can't pass BoolSeries variables in Indicator to Strategy

    I am trying to pass the BoolSeries variables in an indicator for use in my Strategy however, the values doesn't get passed to the strategy at all. I tried to use Print statement to check the values. I only modified line 266 to line 319 of the HeikenAshiSmoothed indicator code (attached the indicator and strategy files). The printed values in the indicators are correct but those in the strategy are incorrect or didn't get passed at all. Not sure where I went wrong in the coding, can anybody help?
    Attached Files

    #2
    Hi tjendra, do you receive any compiling errors on your end? I coundn't import your file to run through the code...are you sure your conditions hit so the boolseries are set to true or false?

    Comment


      #3
      Nope, there is no compiling errors. I use the Print Statement to check if the conditions are hit. The boolseries are correctly set in the indicators as indicated by the print statement but are incorrect when used in the strategy.

      Comment


        #4
        Ok, I would suggest you remove the CalculateOnBarClose setting in the dependant indicators present in your file, some had it, some not. So please make sure you just set the CalculateOnBarClose setting from the strategy. Then retry this and this if the indicator is passed correctly.

        Comment


          #5
          I only had CalculateOnBarClose setting from the strategy, most of the files are exported together with the strategy. The only indicator file that was modified by me was the HeikenAshiSmoothed indicator on line 266 to line 319. The rest of the indicators are just the Moving Average type for use inside the HeikenAshiSmoothed indicator.

          Comment


            #6
            Correct, but please follow the suggestion and remove the assignment in the dependant indicators as I suspect an issue here as this is a known bug when calling indicators from strategies.

            Comment


              #7
              Hi Bertrand, I removed the CalculateOnBarClose = true on the ZLTEMA indicator which is the MA that I am using for the HeikenAshiSmoothed Indicator in my strategy. But I get the same results.

              Comment


                #8
                tjendra,

                It looks like there are many referenced indicators. All of them cannot have the CalculateOnBarClose reference.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  tjendra,

                  It looks like there are many referenced indicators. All of them cannot have the CalculateOnBarClose reference.
                  Hi Josh, I removed all the referenced indicators except for EMA which I use to test. But it still didn't work. Attach the files for your reference.
                  Attached Files

                  Comment


                    #10
                    Please clarify what you mean by 'doesn't work', the strategy fires trades and also the output window shows the exposed boolseries are picked up correctly.

                    Comment


                      #11
                      Originally posted by NinjaTrader_Bertrand View Post
                      Please clarify what you mean by 'doesn't work', the strategy fires trades and also the output window shows the exposed boolseries are picked up correctly.
                      Hi Bertrand, when I backtest the strategy, it only fired 1 trade. Also, if you look at the Print Statements for the strategy, you will see they only return "false" values. The exposed boolseries are not picked up correctly at all in the strategy if you compare it with the print statement values in the indicator at the output window for the exposed boolseries by clicking the Chart tab in Strategy Analyzer. That's why I said it doesn't work correctly.

                      Comment


                        #12
                        Please provide your logs and outputs tjendra. Also use TraceOrders = true in Initialize().
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_Josh View Post
                          Please provide your logs and outputs tjendra. Also use TraceOrders = true in Initialize().
                          Hi Josh, the logs and outputs as requested. Note the print statements with "v3" at the end are called from the strategy files, and the print statements with "v2" at the end are called from the indicator files.
                          Attached Files

                          Comment


                            #14
                            tjendra,

                            That is your problem right there. You need to fix your indicator to not have the object reference errors. You will need to debug this out. It is likely to do with your use of ChartControl. ChartControl is not supported at all by NinjaTrader.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_Josh View Post
                              tjendra,

                              That is your problem right there. You need to fix your indicator to not have the object reference errors. You will need to debug this out. It is likely to do with your use of ChartControl. ChartControl is not supported at all by NinjaTrader.
                              Josh, are you saying the problem is "Error on calling the 'OnBarUpdate' method for indicator 'MyHeiken' on bar 1: Object reference not set to an instance of an object." highlighted in the log file?

                              I'm also not sure what you meant by ChartControl? Can you provide more info on this?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              650 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              370 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              577 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X