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

new Series<int>(this, MaximumBarsLookBack.Infinite) TO .TwoHundredFiftySix)

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

    new Series<int>(this, MaximumBarsLookBack.Infinite) TO .TwoHundredFiftySix)

    new Series<int>(this, MaximumBarsLookBack.Infinite) CONVERSION TO new Series<int>(this, MaximumBarsLookBack.TwoHundredFiftySix)

    I have several indicators that are set as Infinite for testing but will need to be set to TwoHundredFiftySix for trading to save on memory.
    With infinite I can call indicator 1 from indicator 2 with no errors but it turns into a train wreck when set to TwoHundredFiftySix.
    eg. Indicator 2 calls original Indicator 1

    if (Indicator1bar[0] > 0)
    bar 5 = bar 4;
    bar 4 = bar 3;
    bar 3 = bar 2;
    bar 2 = bar 1;
    bar 0 = Indicator1bar[0]

    This works fine only in infinite and corrupts when using the last 256 bars. 256 bars would be enough in real time

    Is there a simple method used to get the right data and would it need to be done I guess, more likely in the original Indicator 1 rather than Indicator 2
    I assume that this is a common requirement but there is no explanation in the help pages and I can't find it in the forum, but I am sure it must have been discussed before.
    Any example would be handy if it has come up before.
    I am thinking maybe:
    1. A different type of series in the original indicator
    2. A new series for every bar from 1 to 5 in the original indicator (there could be about 5 to 10 bars within the 256 bars but more than that is some of the other indicators)
    3. An Array in the original indicator
    I have quite a few indicators to change so I would like to use the most simple and usual method
    Last edited by Ray12345; 01-05-2024, 07:27 AM.

    #2
    Hello Ray12345,

    For a series those are the only two options. If you need more than 256 values you would need to keep infinite selected.

    MaximumBarsLookBack.TwoHundredFiftySix Only the last 256 values of the series object will be stored in memory and accessible for reference (improves memory performance)

    MaximumBarsLookBack.Infinite Allow full access of the series, but you will then not be able to utilize the benefits of memory optimization
    JesseNinjaTrader Customer Service

    Comment


      #3
      Can you create 4 instances of the data series and set two different and then call on the ones that are needed using a boolean if in playback or not a set when connecting live data.
      such that the lookback is only loaded for the type of connection that is the current one.

      Comment


        #4
        Hello LoganJKTrader,

        Yes you could do that. The easiest way would be to make a bool user input that you can toggle in the user interface and then use that to change which series are used in your logic. You would need to make conditions that use that variable wherever you use the series in OnBarUpdate to togget which values you are getting/setting.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by poplagelu, Today, 05:00 AM
        0 responses
        3 views
        0 likes
        Last Post poplagelu  
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,407 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        98 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        8 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        160 views
        0 likes
        Last Post loganjarosz123  
        Working...
        X