Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

issue with series object

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

    issue with series object

    I have the following code and trying to initialize series object based on certain conditions as below.

    Print("Next Trend before if" + NextTrend[0]);
    if (NextTrend[0] == 0)
    {
    HighMin = Math.Min(HighMin, HighestHigh);
    if (Close[0] > High[1])
    {
    Print("Next Trend before" + NextTrend[0]);
    Trend[0] = 0;
    //the Nextrend[0] is reset to zero for somereason on next barupdate
    NextTrend[0] = 1;
    Print("Next Trend after" + NextTrend[0]);
    LowMax = LowestLow;
    }
    }​
    In the beginning of BarUpdate NextTrend[0] is "0" which is good and it goes inside the if condition and NextTrend[0] is assigned "1", however in the next barupdate call, NextTrend[0] is reset to "0". i confirmed it with print statetments as above..

    This line is always zero "Print("Next Trend before if" + NextTrend[0]);​"

    Thanks for the help in advance

    #2
    Hello nagesh789,

    Thank you for your post.

    I'm not following exactly what you mean by "in the next barupdate call" - are you referring to the print immediately after assigning NextTrend[0] = 1 then the print Print("Next Trend after" + NextTrend[0]);​ is output as "Next Trend after0" or something else?

    A custom series holds the same number of values as there are bars in the input series. If the current bar [0] is set to one value, as soon as a new bar begins to form that value then becomes 1 bar ago [1] rather than the current bar [0]. Also, do you have a series called Trend as well? Please provide a reduced sample script that results in the prints you are referring to so I may test on my end and better understand your inquiry. You may export the script via Control Center > Tools > Export > NinjaScript AddOn then attach the .zip file that is generated to your forum reply.

    I look forward to your reply.

    Comment


      #3
      Thanks for a quick reply.

      attached is the sample code with prints. So looks like i have to use NextTrend[1] in the series but not the current bar.

      I will wait for your reply. I have included the entire logic.

      Thanks
      Last edited by nagesh789; 12-21-2023, 08:19 AM.

      Comment


        #4
        Never mind, i think i figured it out..

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        44 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        124 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        65 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X