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

Exposing Plot Values to Strategies

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

    Exposing Plot Values to Strategies

    Hi,

    Can a plot value generated in an indicator be exposed to a strategy the same way as a custom data series? Please advise. Thank you.

    #2
    Hi Zeos6,

    Yes, you can expose indicator plot values from a strategy. The syntax looks like this for a multiplot indicator.

    double myValue = MACD(6, 15, 3).Avg[0];


    If the value is not a plot, the technique is different - shown here:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      HI Ryan,

      Thank you for your email. Is this syntax used in the startegy? Also, how would you add the plots to the strategy for charting purposes? Finally, I am assuming that the plots need not use Update() in the get part of properties.

      Comment


        #4
        Yes, you can access indicator values like that from a strategy.

        This page can help with adding them to a strategy:


        Correct - You do not need Update() when accessing IDataSeries values, like DataSeries, BoolSeries, StringSeries, etc.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thanks Ryan. Much appreciated.

          Comment


            #6
            Hi Ryan,

            So I followed the suggestions and am getting compilation errors in my strategy.

            1. Intellisense tells me I can overload my custom indicator and provide only 4 parameter values yet the compiler objects saying that no overload with 4 parameters exists.

            2. My indicator has 4 plots in it and the strategy compiler complains thatthe first plot does not exist in the current context.

            Any suggestion would be greatly appreciated. Thank you.

            Comment


              #7
              I'm not sure. If you can attach the script here will give a look. You can also consider building your expression in the condition builder to see the syntax used. This also has an option to set plot on chart = true so you can see the syntax for the Add() statement in Initilize().
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Thanks Ryan. Using the condition builder did the trick. It turns out that when all the parameters are included the strategy compiles correctly.

                One final question, however:
                I have multiple plots in the indicator and a number of parameters. I tried reassigning the indicator with the parameters as follows:

                double TUp = PB_Tup(par1, par2, par3, ...)
                then I wanted to use
                TUp.Plot1Name[0]

                but the compiler complains it cannot convert the types. Any suggestions?
                Last edited by Zeos6; 06-15-2011, 01:41 PM.

                Comment


                  #9
                  For this you have to use your indicator name as type. In Variables region:
                  private PB_Tup TUp;

                  Then, in OnStartUp or OBU assign its value:

                  if (TUp == null)
                  TUp = PB_Tup(par1, par2, par3, ...);
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by Zeos6 View Post
                    Hi Ryan,

                    So I followed the suggestions and am getting compilation errors in my strategy.

                    1. Intellisense tells me I can overload my custom indicator and provide only 4 parameter values yet the compiler objects saying that no overload with 4 parameters exists.

                    2. My indicator has 4 plots in it and the strategy compiler complains thatthe first plot does not exist in the current context.

                    Any suggestion would be greatly appreciated. Thank you.
                    One of the quirks of the NinjaTrader framework. Unfortunately, it has been my experience that Custom Indicators MUST be called with ALL their required parameters, despite the overrides that Intellisense sometimes suggests are available.

                    Comment


                      #11
                      Hi Ryan,

                      Thanks for your reply. This code produces a compiler error stating that there is a clash between the type and the namespace PB_Tup.

                      Comment


                        #12
                        The exact syntax will vary based on your code. Attached is an example you can use.
                        Attached Files
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks Ryan. I have this issue resolved now. I inadvertently created a namespace to hold my public enums that was named PB_TUp.PublicEnums and that was the source of the conflict. Thank you very much for all your help.

                          One follow up question. The plots can be teted if they contain a valid plotable value using the .ContainsValue() method. This does not carry over to the strategy. Should I be using Reset() to set the plot values to null and then checking for null in my strategy? Please advise. Thank you.
                          Last edited by Zeos6; 06-15-2011, 03:23 PM.

                          Comment


                            #14
                            Hello, I think you can do this and expose indicator plot values you garner from a specific strategy. I am not sure though how it would look like in the syntax level. You can try using condition builder if you can't do it with anything else. You will also be required to plug in all the necessary parameters in order for it to compile correctly.

                            Comment


                              #15
                              Hi cedricf,

                              I appreciate you attempting to answer this question but you are missing the point of the question. Of course you can expose the plot values in a strategy. That is not the issue here. The real issue is that unless a plot value is actually set in your indicator, it contains a place holder equivalent to the close of the bar, and you can test for valid values of the Plot using the .ContainsValue() method in your indicator.

                              The issue here is...
                              When Plot values are exposed in a strategy, what value is being eposed when a values has not been explicitly set in the indicator? Will the value exposed be the place holder value or will I get a null or 0?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Rapine Heihei, Today, 08:19 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Rapine Heihei, Today, 08:25 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Rapine Heihei  
                              Started by f.saeidi, Today, 08:01 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Rapine Heihei, Today, 07:51 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post Rapine Heihei  
                              Started by frslvr, 04-11-2024, 07:26 AM
                              5 responses
                              98 views
                              1 like
                              Last Post caryc123  
                              Working...
                              X