• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


Continued: Coding multi data series unresolved.

  • Filter
  • Time
  • Show
Clear All
new posts

    Continued: Coding multi data series unresolved.

    Hello NinjaTrader_ChelseaB

    Sorry for starting a new thread, its been over a week since I last made a post on this issue. I had to go out of state for a week and I have returned, performing more tests to iron out what is going on.

    As a refresher, I have a data series using a custom RENKO bar that is defined as follows:

    else if (State == State.Configure)
    //AddRenko(null, 8, MarketDataType.Last);
    AddDataSeries(null, new BarsPeriod { BarsPeriodType = (BarsPeriodType)1995, Value = 8, Value2 = 3, BaseBarsPeriodValue = 50, MarketDataType = MarketDataType.Last});
    After your suggestion of changing from the AddRenko to AddDataSeries, I am now obtaining the correct close values for the Closes[1] price series.

    I now have the following section of code that is producing the results in the attached image:

    if (CurrentBars[0] < 1 || CurrentBars[1] < 1) return;

    if (BarsInProgress == 1)
    eCloseHolder = Closes[1][0];
    extClose[0] = eCloseHolder;

    double thTrend = 0;
    double thHammer = 0;

    jelTHExt(ref thTrend, ref thHammer, Closes[1], CurrentBar);

    extHammer[0] = thHammer;
    extTrend[0] = thTrend;

    Print ("thHammer: " + thHammer.ToString() + " ** " + extHammer[0].ToString() + " | thTrend: " + thTrend.ToString() + " ** " + extTrend[0].ToString());
    Print ("thHammer[0]: " + extHammer[0].ToString() + " thHammer[1] " + extHammer[1].ToString());

    double tmpTHDir = 0;

    if (extTrend[0] > extTrend[1])
    tmpTHDir = 2;
    if (extTrend[0] < 0) tmpTHDir = 1;

    if (extTrend[0] < extTrend[1])
    tmpTHDir = -2;
    if (extTrend[0] > 0) tmpTHDir = -1;

    Print("dir: " + tmpTHDir.ToString());

    if (tmpTHDir < 0) extDirTH[0] = -1;
    if (tmpTHDir > 0) extDirTH[0] = 1;

    Print("******************************************* **SECONDARY CLOSE: " + Closes[1][0].ToString() + "******************************************");
    Print("************* TH-DIR: " + extDirTH[0].ToString());

    jelTHExt is a function that returns a value into thTrend and thHammer when BarsInProgress ==1 using the close of the secondary data series. The values stored in these double variables contain the correct values. I am storing each of these values in there respective Series<double> variables extHammer and extTrend. After storing the value of thHammer into thHammer[0] and then performing a thHammer[0].ToString() in a print statement, I am being returned the correct value. However, thHammer[x] where X >=1 returns an incorrect value. Something is changing the values in the data series that contains previous values.

    On the bright side, I think we are getting closer. All I need now to return previous values calculated from my function.

    Click image for larger version

Name:	issuex3.png
Views:	14
Size:	1,006.4 KB
ID:	1058804

    Hello MarthaClines,

    Thanks for your post.

    Are you expecting that the Series<double> is synchronized with the secondary data series? The Series<double> will only contain slots which are synchronized with the primary data series. In other words, we are actually assigning "The value that was last seen when the primary bar iterates" when we assign a value from an added data series to a Series or plot.

    You could consider using a Dictionary instead of a Series object as that object will not be synchronized to the primary data series, or you could use an array to specifically hold the last X number of values for a secondary series.

    Dictionary (Publicly available MSDN documentation) - https://docs.microsoft.com/en-us/dot...tframework-4.5

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service


    Latest Posts


    Topics Statistics Last Post
    Started by Johnny Santiago, Today, 06:18 PM
    1 response
    Last Post Johnny Santiago  
    Started by EnveousColnago, Today, 05:43 PM
    0 responses
    Last Post EnveousColnago  
    Started by Zigfried, Today, 02:30 PM
    2 responses
    Last Post Zigfried  
    Started by lunardiplomacy, Today, 11:35 AM
    4 responses
    Last Post lunardiplomacy  
    Started by silverm3170, Today, 11:24 AM
    3 responses
    Last Post NinjaTrader_Jesse