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

    #16
    Zeos,

    I'm not familiar with the issue you present. If you can post a sample indicator and strategy file I will check it out here. Thank you.
    Ryan M.NinjaTrader Customer Service

    Comment


      #17
      Hi Ryan,

      I am confused by your reply. I thought the question was fairly straight forward.
      Anyways, suppose I have an indicator in which I do the following:

      int[] bars = new int[] {1,3,5,7,9};
      foreach(int i in bars)
      {
      myPlot.Set(100);
      }

      Clearly myPlot.ContainsValue() will be false for even bars less than 10.

      Now assume I expose this indicator plot (myPlot) to a strategy. How can I test in the strategy if myPlot contains a set value? .ContainsValue() does not work in the strategy. Do I use

      if(myPlotValue != null ) do something
      or
      if(MyPlotValue > 0) do something

      Comment


        #18
        Set it to a dummy value.
        Code:
        int dummy = -9999;
        int[] bars = new int[] {1,2,3,4,5,6,7,8,9};
        foreach(int i in bars)
        {
            //if odd bar
            if(i % 2==1)
                myPlot.Set(i, 100);
            else
                myPlot.Set(i, dummy);
        }

        Comment


          #19
          Hi nailz420,

          Thanks for your post. Your code is same as

          int[] bars = new int[] {1,2,3,4,5,67,8,9};
          foreach(int i in bars)
          { //if odd bar
          if(i % 2==1) myPlot.Set(i, 100);
          else myPlot.Reset();}
          }

          However, you are missing the point. The point is whether I need to do this Reset or dummy variable assign in the first place in order to distinguish between a set and dummy value in a strategy or whether a Plot that has not been set defaults to null or zero in the strategy.
          Last edited by Zeos6; 06-16-2011, 09:00 AM.

          Comment


            #20
            I don't think there is a way to do this by default. I would make a copy of the indicator in which I want to be able to distinguish the set or defaulted plot values and customize it to implement the dummy value.

            Comment


              #21
              Thanks nailz420. So am I to understand that you are saying I need to use the Reset() in my indicator/plot (to assign a non plotting value of zero and then in my strategy I simply use if(myPlot[0] > 0) do something?

              Comment


                #22
                Something like that, I am just not sure or trust how Reset() works.

                Comment


                  #23
                  Thanks nailz420. Reset() sets a non plotting mathematical zero value.

                  Comment


                    #24
                    Okay. I think I have this figured out. For anyone who may be interested here it goes:

                    As far as I can tell, not setting a Plot value (or applying the Reset() to a Plot value) will cause the data series to hold a non-plottable value that is equal to the bar's close value. The .ContainsValue() will return a false for these bars.

                    In your strategy you can apply the .ContainsValue() method to determine if the exposed plot value for the bar is a valid set value. The syntax for the current bar is myPlot.ContainsValue(0). It will return a true or false depending on whether the value was set in your indicator. I hope this helps.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by XXtrader, Yesterday, 11:30 PM
                    2 responses
                    11 views
                    0 likes
                    Last Post XXtrader  
                    Started by Waxavi, Today, 02:10 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post Waxavi
                    by Waxavi
                     
                    Started by TradeForge, Today, 02:09 AM
                    0 responses
                    11 views
                    0 likes
                    Last Post TradeForge  
                    Started by Waxavi, Today, 02:00 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post Waxavi
                    by Waxavi
                     
                    Started by elirion, Today, 01:36 AM
                    0 responses
                    7 views
                    0 likes
                    Last Post elirion
                    by elirion
                     
                    Working...
                    X