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

Continued: Coding multi data series unresolved.

Collapse
X
 
  • 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:	170
Size:	1,006.4 KB
ID:	1058804

    #2
    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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Tim-c, Today, 02:10 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    1 view
    0 likes
    Last Post Taddypole  
    Started by chbruno, 04-24-2024, 04:10 PM
    4 responses
    50 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    10 responses
    399 views
    1 like
    Last Post beobast
    by beobast
     
    Started by lorem, Yesterday, 09:18 AM
    5 responses
    23 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X