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 judysamnt7, 03-13-2023, 09:11 AM
    4 responses
    59 views
    0 likes
    Last Post DynamicTest  
    Started by ScottWalsh, Today, 06:52 PM
    4 responses
    36 views
    0 likes
    Last Post ScottWalsh  
    Started by olisav57, Today, 07:39 PM
    0 responses
    7 views
    0 likes
    Last Post olisav57  
    Started by trilliantrader, Today, 03:01 PM
    2 responses
    22 views
    0 likes
    Last Post helpwanted  
    Started by cre8able, Today, 07:24 PM
    0 responses
    10 views
    0 likes
    Last Post cre8able  
    Working...
    X