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

Switch to not load indicator

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

    Switch to not load indicator

    I have a strategy that is really slow to optimize, because it calls for a custom indicator.
    Is there a way to have an input variable (bool) to only load the custom indicator in State = State.Realtime and not in backtest?

    Optimization speed is a lot faster when I remove the custom indicator from my strategy script.



    #2
    Hello YakusaTrader,

    Thank you for the post.

    Yes, this should be possible, where do you use the indicator in the script is this from State.DataLoaded or is it being used in your logic in OnBarUpdate? It would really depend on how it's being used and if it can be totally removed during historical bars. If it's only visually being used, you can just surround its code with an if statement checking your inputs value. If it's used in your logic, that may not be able to be removed as that would prevent your logic from working.


    I look forward to being of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks for your help. I use it in (State == State.DataLoaded) but only conditionally:

      else if (State == State.DataLoaded)
      {
      if (BackTest == false)
      {
      MyCustomIdicator = MyCustomIdicator1(MyCustomIdicator);
      AddChartIndicator(MyCustomIdicator);
      }
      }


      I also use it OnBarUpdate, but again conditionally"

      if (BackTest == false)
      {
      if (MyCustomIdicator1 > 0)
      {
      Print(MyValue);
      }
      BackTest is an input variable (bool) that I turn on during optimization, but it's not helping.

      Comment


        #4
        Hello YakusaTrader,

        Can you explain what you mean that it's not helping? Is this not toggling the indicators or what are you seeing happen?

        Have you also tried to navigate away from the current strategy to a different one, then back to this strategy?

        I can see on my end that toggling the indicators like this does work in the analyzer, however in your use case from OnBarUpdate if there is any logic using that indicator that will affect the strategies results.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          It's toggling off the indicator, however, optimization speed is slower compared to completely removing the indicator from my script.

          If Backtest == false, then it's really really slow.
          If Backtest == true, then it's slow (it uses lots of memory).
          If the indicator's script is removed from my strategy, then it's fast.

          Let me be clear, the custom indicator I am using is a news release indicator that pulls out Data (news time) from the internet and stores it.
          I only need this indicator to work in real trading and not backtest / historical.

          Comment


            #6
            Hello YakusaTrader,

            Thank you for your reply.

            I couldn't really say what may be happening in that example, it sounds like the indicator is still being called somewhere. If the indicator is being toggled off it should no longer be used. If you have the source code for the indicator, you may try adding in a print to see if the indicator is still being called somewhere from your script.

            Alternatively, you could comment out the indicator to disable it while backtesting if you cannot find a solution using the conditions.

            You could also try making a more simple test with the SampleMACrossover that just toggles the indicator to see if you can replicate the problem. If so, and if the indicator is an open source item you could provide that as a sample of the problem for further review.


            Please let me know if I may be of additional assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              I currently comment out the indicator from my strategy script, but the problem is: I have 2x of the same indicator, one for trading and 1x for backtest, which is not ideal.

              Anyway thanks for your help, I will investigate further and will let you know.

              Comment


                #8
                I am sorry, I meant 2x of the same strategy, not indicator.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by techgetgame, Today, 11:42 PM
                0 responses
                7 views
                0 likes
                Last Post techgetgame  
                Started by sephichapdson, Today, 11:36 PM
                0 responses
                1 view
                0 likes
                Last Post sephichapdson  
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,612 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                9 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                19 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Working...
                X