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

Getting Historical Values Using DataSeries..

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

    Getting Historical Values Using DataSeries..

    Hello-

    I am new to Ninja Trader migrating from Tradestation. I am currently converting some code with some success. My programming skills are rudimentary, certainly not great.

    I am currently bumping up against some walls in using DataSeries and was hoping someone with greater experience could lend a hand.

    Summary:
    I am trying to compare values of a data series by referencing the variable and then using the brackets to specify the historical bar.

    Example:
    if (RSIWeightedAverage[0] < RSI RSIWeightedAverage[1]) &&
    (RSIWeightedAverage[1] < RSI RSIWeightedAverage[2])
    {
    Print("RSIWAvg is falling.");
    }


    Problem:
    Prior to adding this statement or any statement that references historical bars, I am able to print out the values correctly. The problem is that once I try and reference any historical value, it DOES compile, but the value is way off. It is no longer between 1 and 100 and all of my variables equal each other...in this case 825.6.

    Example:
    In summary, I am able to get the value for this:

    RSIWAvg.Set(WMA(_RSI,13)[0]);
    Print("WRSI is: " + RSIWAvg);

    This prints the number: 36.69 (a valid RSI #)

    but get a false value (again, it compiles) for this:

    RSIWAvg.Set(WMA(_RSI,13)[0]);
    Print("WRSI is: " + RSIWAvg[3]);

    This prints the number: 826.6 and all other variables print the same number. (not a valid RSI value)

    Any help is greatly appreciated.

    Nick
    Last edited by nmussa; 10-02-2007, 04:40 PM. Reason: Editing title to make it more specific.

    #2
    Hi nmussa,

    Please check the values of your _RSI DataSeries. I suggest plotting that DataSeries and seeing what it looks like. I suspect the values are off when you set that DataSeries.

    Also please check out this link for help with debugging: http://www.ninjatrader-support.com/v...6558#post16558
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh, thanks for responding. _RSI, RSIAvg, and RSIWAvg are established as follows (Code shortened for brevity):

      Variables:
      private DataSeries _RSI;
      private DataSeries _RSI;
      private DataSeries RSIAvg;

      protected override void Initialize()..
      _RSI = new DataSeries(this);
      RSIAvg = new DataSeries(this);
      RSIWAvg = new DataSeries(this);

      protected override void OnBarUpdate()
      _RSI.Set(RSI(Close,7,0)[0]);
      Print("RSI is: " + _RSI);
      //Print("RSI is: " + _RSI[1] + " " + _RSI[2]);

      RSIAvg.Set(SMA(_RSI,50)[0]);
      Print("RSIAvg: " + RSIAvg);

      RSIWAvg.Set(WMA(_RSI,3)[0]);
      Print("WRSI is: " + RSIWAvg);

      The output of this is:

      WRSI is: 1.32105414045233
      RSI is: 2.11233505776232
      RSIAvg: 42.2158694944319
      WRSI is: 1.74686223061979
      RSI is: 2.10626399743948
      RSIAvg: 41.8393368424933
      WRSI is: 1.98747525188672

      If I make this change and switch the commented lines to:

      //Print("RSI is: " + _RSI);
      Print("RSI is: " + _RSI[1] + " " + _RSI[2]);

      Then everything compiles and there are no errors, but I recieve no output. I can get a test print statement out of the initialize section. Print("This is a test.); does print once.

      Since there is no error, I am at a loss on how to proceed next. Thanks again for your time.

      Nick

      Comment


        #4
        If an indicator/strategy does not produce output, always look at the Control Center Log tab for runtime errors.

        This "Tip" will likely solve your problem.

        RayNinjaTrader Customer Service

        Comment


          #5
          That did it. I did not know about the Log tab for development. Good stuff.

          Both of your help is much appreciated.
          Last edited by nmussa; 10-03-2007, 07:07 PM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by hazylizard, Today, 08:38 AM
          2 responses
          8 views
          0 likes
          Last Post hazylizard  
          Started by geddyisodin, Today, 05:20 AM
          2 responses
          18 views
          0 likes
          Last Post geddyisodin  
          Started by Max238, Today, 01:28 AM
          5 responses
          47 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by giulyko00, Yesterday, 12:03 PM
          3 responses
          13 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by habeebft, Today, 07:27 AM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_ChristopherS  
          Working...
          X