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

Plot Series Historical Bars Erase, Clear, Reset... Example Code

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

    Plot Series Historical Bars Erase, Clear, Reset... Example Code

    I'm trying to erase or clear a previous plot when a new session starts, because the previous plot may have had a value of -9,000 and when the new plot starts at 0, the chart auto scale will make it difficult to view the newest plot values.

    Some topics in the forum have noted that you need to iterate through the series that is used to hold values for the plot, but i have not seen an example.

    I have written this code, and it seems to work correctly when tested on a playback connection.

    Code:
    // reset all previous values used in plot CountOfTrumpTweetsAgainstAmazon
    for( int seriesindex = 0; seriesindex < CountOfTrumpTweetsAgainstAmazon.Count; seriesindex++	)
    {	// reset the series value at this index pointer
    	CountOfTrumpTweetsAgainstAmazon[seriesindex] = 0.0;
    	Print("resetting series value at index " + seriesindex );
    }
    Please confirm this is the best practice, and there is no Series<T>.Clear() method which would be able to avoid the iteration through all bars in the historical series.


    The speed of this operation appears to be very fast when tested on a playback connection running at 1x speed, even though it is printing to the Ninjascript Output window at each bar index pointer as a debug test.

    Code:
    resetting series value at index 5417
    resetting series value at index 5418
    Please discuss if the speed of this reset would still be as fast when used in real-data data feed. I hypothesize it is simply a O(n) operation, and duration will depend upon the count of the number of bars in the series, the CPU speed and memory consumption, but it does not appear to be a bottleneck concern for me, since it is only done at the start of new session.

    #2
    Hello balltrader,

    Thank you for your note.

    There is no Series clear method and the loop you are using looks fine. There may be many ways to accomplish the same thing and would not be able to comment on what is best.

    Playback simulates real time and I would not expect a significant difference in the time it takes to run the loop.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    26 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    32 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, Yesterday, 09:53 PM
    2 responses
    49 views
    0 likes
    Last Post wzgy0920  
    Started by Kensonprib, 04-28-2021, 10:11 AM
    5 responses
    192 views
    0 likes
    Last Post Hasadafa  
    Started by GussJ, 03-04-2020, 03:11 PM
    11 responses
    3,234 views
    0 likes
    Last Post xiinteractive  
    Working...
    X