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

How to make 2 values accessible via the Strategy Builder

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

    How to make 2 values accessible via the Strategy Builder

    Hello,

    I have an indicator I am using, but I want to use two values from it which are ibHigh and ibLow, I saw in previous posts you mention it needs to be public, and I can see in properties section it shows it is public with a getter:

    [Browsable(false)]
    [XmlIgnore()]
    public double IBLow
    {
    get { return this._ibLow; }
    }

    But when I open the SB there is no such value to choose to plot as (to backtest) can you please assist as to what needs to be added to make it accessible?

    The indicator is attached.


    Many thanks​
    Attached Files

    #2
    Hello gummybar,

    Thank you for your post.

    Plots must be specifically added with AddPlot() in order for the values to be exposed in the Strategy Builder, and there must be a Series<double> variable that returns the Values[plot index].

    AddPlot() - https://ninjatrader.com/support/help...t8/addplot.htm
    Values - https://ninjatrader.com/support/helpGuides/nt8/values.htm

    Please see this forum post that goes into detail on exposing indicator plot values in the Strategy Builder:
    https://forum.ninjatrader.com/forum/...64#post11822644

    In your script, you have defined 5 plots however the values for these plots are never assigned, and neither are the public Series<double>s required to return the Values[].

    You have also overriden OnRender(), however base.OnRender is never called to ensure the plots are rendered along with your custom render logic.

    Please see the second example code block from the following Help Guide page:


    If you have any other questions, please let us know.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Gaby View Post
      Hello gummybar,

      Thank you for your post.

      Plots must be specifically added with AddPlot() in order for the values to be exposed in the Strategy Builder, and there must be a Series&lt;double&gt; variable that returns the Values[plot index].

      AddPlot() - https://ninjatrader.com/support/help...t8/addplot.htm
      Values - https://ninjatrader.com/support/helpGuides/nt8/values.htm

      Please see this forum post that goes into detail on exposing indicator plot values in the Strategy Builder:
      https://forum.ninjatrader.com/forum/...64#post11822644

      In your script, you have defined 5 plots however the values for these plots are never assigned, and neither are the public Series&lt;d , ouble&gt;s required to return the Values[].

      You have also overriden OnRender(), however base.OnRender is never called to ensure the plots are rendered along with your custom render logic.

      Please see the second example code block from the following Help Guide page:
      https://ninjatrader.com/support/help...8/onrender.htm

      If you have any other questions, please let us know.
      Thank you for the detailed reply, I think I managed to get it to work somewhat!
      However I am having a very strange issue when running my strategy in the analyzer, even though I am running it for entire year or 2023, when looking at the chart it only goes back less than a month! might be a general issue with the indicator itself, can you help explain what is happening, why is it limited to less than a month and how can it be increased?

      I've attached the updated script, it won't allow me to attach the strategy but you should be able to replicate it by just attaching the indicator and looking at the chart or creating some simple strat.
      Attached Files
      Last edited by gummybar; 12-30-2023, 04:57 PM.

      Comment


        #4
        Hello gummybar,

        The issue may be with the secondary series added with AddDataSeries().

        Note, the AddDataSeries() calls are being dynamically called with an if statement which is not supported.

        Use prints to confirm if the series have data. Print the time of the bar, the BarsInProgress, and the CurrentBars[barsInProgressIndex].

        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello gummybar,

          The issue may be with the secondary series added with AddDataSeries().

          Note, the AddDataSeries() calls are being dynamically called with an if statement which is not supported.

          Use prints to confirm if the series have data. Print the time of the bar, the BarsInProgress, and the CurrentBars[barsInProgressIndex].
          Actually I just tested something, I tried to run with MNQ MAR24 Contract, and I get trades earliest from 19th Dec


          And MNQ DEC23 and I get the earliest trade from 23rd Nov

          Is there no way to make it automatically connect all the contracts together? it was doing it just fine in the past or could it still be something with the code? but how come

          Comment


            #6
            Hello gummybar,

            What Merge Policy are you currently using?

            Your your Merge Policy setting will determine how historical data is processed when backtesting in the Strategy Analyzer.

            Please see this forum post which explains in detail:



            If you have any other questions, please let us know.
            Gaby V.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Gaby View Post
              Hello gummybar,

              What Merge Policy are you currently using?

              Your your Merge Policy setting will determine how historical data is processed when backtesting in the Strategy Analyzer.

              Please see this forum post which explains in detail:



              If you have any other questions, please let us know.
              It was set to default, I changed it even now specifically for MNQ to merge back adjusted, and the is is still there when I test.

              Comment


                #8
                Hello,

                Are you saying the issue is still there when you backtest?

                What is the earliest data that is loading on the chart, and how many days to load or what date range is being set?

                I look forward to your response.
                Gaby V.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Gaby View Post
                  Hello,

                  Are you saying the issue is still there when you backtest?

                  What is the earliest data that is loading on the chart, and how many days to load or what date range is being set?

                  I look forward to your response.
                  Hi that is correct, the issue remains, but seems to only occur when I use this indicator strategy I mentioned, and doesn't occur with others, not sure how to move from here.

                  It seems to just load the data depending on which contract date I choose up to its start time (3 months approx backwards)

                  It seems the same issue appears on the chart itself! when looking at the chart today with MNQ MAR24 it only shows the IB ranges up to JAN 25 !

                  Any ideas?

                  Thanks

                  Comment


                    #10
                    Hello gummybar,

                    Have you opened a chart to the latest expiry contract month and the full date range selected, and reloaded all historical data?

                    "*Critical* After making any changes to the Merge policy, you must right-click a chart for that instrument / data type and select Reload All Historical Data.​"
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by LiamTwine, Today, 08:10 AM
                    0 responses
                    0 views
                    0 likes
                    Last Post LiamTwine  
                    Started by Balage0922, Today, 07:38 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post Balage0922  
                    Started by JoMoon2024, Today, 06:56 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post JoMoon2024  
                    Started by Haiasi, 04-25-2024, 06:53 PM
                    2 responses
                    19 views
                    0 likes
                    Last Post Massinisa  
                    Started by Creamers, Today, 05:32 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post Creamers  
                    Working...
                    X