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

Setting the value for historical bars.

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

    Setting the value for historical bars.

    I want to predict the max. price change 3 bars into the future. Therefore when I generate my data set, what I am trying to predict/forecast has to be placed back 3 bars ago. Hope I said the correctly.

    So the DataSeries Class Set method has a format of DataSeries.Set(int, barsago, double value); So my simple indicator the has the price change for 3 bars into the future is:
    protected override void OnBarUpdate()
    {

    //Trgt.Reset();
    if(CurrentBar < lookBack) return;
    if( Close[0] - Close[lookBack] >= 0.00 )
    {
    Trgt.Set(lookBack, High[HighestBar(High,lookBack)] - Close[lookBack] );
    }
    else Trgt.Set(lookBack, Low[LowestBar(Low,lookBack)] - Close[lookBack] );
    }

    Now when adding this indicator to a chart everything is plotted correctly. The last 3 bars, right edge are empty. As they should be.

    The problem comes in when I try and use this indicator in another indicator in which I create the file that contain all of the data that I want to train on. The script: SampleStreamWriter was used as the basis to create the file. I do not get the correct value from the indicator. I am getting some price from somewhere. The name of the indicator is MyTarget. Here is some of the code where I write everything to the file.

    Print("Time:" + Time[lookback].ToString() + " Target: " +MyTarget(Close,lookback).Trgt[3].ToString());

    sw.WriteLine(Time[lookback].ToString()
    + "," + Close[lookback]
    + "," + High[lookback]
    + "," + Low[lookback]
    + "," + Close[lookback + 1]
    + "," + High[lookback + 1]
    + "," + Low[lookback + 1]
    + "," + Close[lookback + 2]
    + "," + High[lookback + 2]
    + "," + Low[lookback + 2]
    + "," + DinapoliStochastic(Close, 3, 3, 5).LineK[lookback]
    + "," + DinapoliStochastic(Close, 3, 3, 5).LineD[lookback]
    + "," + DinapoliStochastic(Close, 3, 3, 5).LineK[lookback + 1]
    + "," + DinapoliStochastic(Close, 3, 3, 5).LineD[lookback + 1]
    + "," + DinapoliStochastic(Close, 3, 3, 5).LineK[lookback + 2]
    + "," + DinapoliStochastic(Close, 3, 3, 5).LineD[lookback + 2]
    + "," + MyTarget(lookback)[3] );

    I have been able to verify that all of the data being exported to the file is correct except for what MyTarget()[3] is returning. The data is being returned is not even close. As I said, it's some kind of price data.

    Is there something about using barsago in the Set method that I have failed to understand?

    Thanks

    #2
    Perhaps you are running into updating issues. Please see the Help Guide document on Update().
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      If I use the normal method of Set:
      Trgt.Set( High[HighestBar(High,lookBack)] - Close[lookBack] );

      Then calling this indicator from another indicator gives me the correct results. After making the appropriate adjustment i.e.
      + MyTarget(lookback)[0]


      Read about the Update() method but not sure if this would fix the problem. Not sure if the Update() would need to be added to my 1st indicator or the second indicator. Also, the second indicator is not plotting anything. The 2nd indicator is just writing a a bunch of lines/records to a text file.

      Comment


        #4
        Not sure what your issue is. You need to reference the plot that has value. Referencing just the indicator generally won't yield values from the particular plot you want. If you are using DataSeries objects things are generally kept up to date for you. You will need to debug to find what values it is returning.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Pattontje, Yesterday, 02:10 PM
        2 responses
        14 views
        0 likes
        Last Post Pattontje  
        Started by flybuzz, 04-21-2024, 04:07 PM
        17 responses
        229 views
        0 likes
        Last Post TradingLoss  
        Started by agclub, 04-21-2024, 08:57 PM
        3 responses
        17 views
        0 likes
        Last Post TradingLoss  
        Started by TradingLoss, 04-21-2024, 04:32 PM
        4 responses
        43 views
        2 likes
        Last Post TradingLoss  
        Started by cre8able, 04-17-2024, 04:16 PM
        6 responses
        56 views
        0 likes
        Last Post cre8able  
        Working...
        X