Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding Indicator to Strategy

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

    Adding Indicator to Strategy

    What is the appropriate syntax?

    I can create the indicator and it will chart, but then said value will not appear in my strategy?

    Regards,

    Andrew


    This is the code that will chart but not translate (ignore the manual SMA, I am checking my math value by value):

    Indicator (name is VolumePlots):

    Code:
    Add(PeriodType.Day, 1);            
    
    BarsRequired = 20;
    
    
    Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "plotIntradayVolume"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "plotTenDayAvgVol"));
    
    }
    
           
            protected override void OnBarUpdate()
            {
                
    	if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
                return;	
    			
    	intradayVolume = Volumes[1][0];
    			
    tenDayAvgVol = (Volumes[1][1] + Volumes[1][2] + Volumes[1][3] + Volumes[1][4] + Volumes[1][5] + Volumes[1][6] + Volumes[1][7] + Volumes[1][8] + Volumes[1][9] + Volumes[1][10])/10;
    			
    plotIntradayVolume.Set(intradayVolume);
    plotTenDayAvgVol.Set(tenDayAvgVol);
            
    }
    
            #region Properties
    		
    	public DataSeries plotIntradayVolume
            {
                get { return Values[0]; }
            }	
    		
    		
    	public DataSeries plotTenDayAvgVol
            {
                get { return Values[1]; }
            }
    Strategy:
    Code:
    cumVolume = VolumePlots().intradayVolume;
    Print(cumVolume);
    
    avgVolume = VolumePlots().tenDayAvgVol;
    Print (avgVolume);
    In fact what is being printed in all cases is the last price of the equity in question

    Any help appreciated,

    Regards,

    Andrew
    Last edited by alabell; 11-20-2012, 10:05 AM.

    #2
    Hello alabell,

    Thank you for your post.

    Please provide a working sample of your indicator (including the variables, declarations and properties) so I may test on my end.

    I look forward to your response.

    Comment


      #3
      Here it is Patrick.

      Thanks and regards.

      Andrew
      Attached Files

      Comment


        #4
        Hello Andrew,

        Thank you for your response.

        I cannot get the indicator to plot, please provide the details on what instrument, period type, and interval value you are running your indicator on as well as attaching a screenshot of your chart to your response.

        I look forward to your response.

        Comment


          #5
          Just put up a daily chart with 365 bars (so a one year chart of daily bars). Heres a shot of ORCL.
          Attached Files
          Last edited by alabell; 11-20-2012, 11:34 AM.

          Comment


            #6
            Hello Andrew,

            Thank you for your response.

            Please set your Strategy to CalculateOnBarClose = False and then test again, do you see the correct values in the Output Window?

            I look forward to your response.

            Comment


              #7
              No, it does not. While the information in the Market Anazlyzer has suddenly updated and is correct, my printout of the values from my strategies has changed from "last trade price" (of the stock in question ORCL) to "NaN" or zero.

              Also please be aware, that coding an indicator with OnBarClose = true and adding it to my strategy was suggested to me yesterday, although not with a lot of detail as to nuances.

              See below thread.

              http://www.ninjatrader.com/support/f...ad.php?t=53995

              What I am asking for is, or should not be, very hard-- given the nature of the business we are dealing in.

              Regards,

              Andrew
              Last edited by alabell; 11-20-2012, 12:29 PM.

              Comment


                #8
                Hello Andrew,

                Thank you for your response.

                There is an anomaly I am not seeing here as I am able to get the correct values in the Output Window using your indicator for my strategy. Would there be any possibility I can test a 'toy' version of your strategy here on my end?

                If you prefer you can send it to support[at]ninjatrader[dot]com with ATTN: Patrick in the subject line and a reference to this thread in the body of the e-mail: http://www.ninjatrader.com/support/f...ad.php?t=54021

                I look forward to assisting you further.

                Comment


                  #9
                  Hello Andrew,

                  I would like to add that both Adam and I are referring to the same test here. Please try setting CalculateOnBarClose to False and test again.

                  Reference the following post on your thread with Adam: http://www.ninjatrader.com/support/f...97&postcount=4

                  I look forward to your response.

                  Comment


                    #10
                    I am sending it now. I replaced a proprietary variable with your name, feel free to define it as a double and use any relevant price value and the code will compile.

                    And yes, I did the change already. onbarclose is set to false. both in initialize and in gui.

                    Regards,

                    Andrew
                    Last edited by alabell; 11-20-2012, 01:41 PM.

                    Comment


                      #11
                      Hello Andrew,

                      Thank you for that file.

                      I will follow up with you via e-mail.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by MacDad, 02-25-2024, 11:48 PM
                      7 responses
                      158 views
                      0 likes
                      Last Post loganjarosz123  
                      Started by Belfortbucks, Today, 09:29 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post Belfortbucks  
                      Started by zstheorist, Today, 07:52 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post zstheorist  
                      Started by pmachiraju, 11-01-2023, 04:46 AM
                      8 responses
                      151 views
                      0 likes
                      Last Post rehmans
                      by rehmans
                       
                      Started by mattbsea, Today, 05:44 PM
                      0 responses
                      6 views
                      0 likes
                      Last Post mattbsea  
                      Working...
                      X