NexusFi: Find Your Edge


Home Menu

 





List to DataSeries


Discussion in NinjaTrader

Updated
    1. trending_up 1,488 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
victorg20013
Los Angeles
 
Posts: 11 since Feb 2017
Thanks Given: 3
Thanks Received: 0

Hi I have a list, and want to create a DataSeries if that's possible.

Currently, my List shows as follows,

Both[0]-1062
Both[1]-1057
Both[2]-1056
Both[3]-1050
Both[4]-1045
Both[5]-1046
Both[6]-1041
Both[7]-1042
Both[8]-1033
Both[9]-1038
Both[10]-1030

as you can see, its supposed to decrement, but on Both[5] it increments.

I want to be able to remove it if it increments, but when I use (Both[x-1]) in the for loop condtional on a list I get an error.
It seems as though I can't use indexing on a list the same way as on a DataSeries, as you can do that on a dataseries.

This is what I want:

Both[0]-1062
Both[1]-1057
Both[2]-1056
Both[3]-1050
Both[4]-1045

Both[5]-1041

Both[6]-1033

Both[7]-1030

either as a dataseries or list.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Five Days Until the Gap Dies -- CME Goes 24/7 on All Dig …
Traders Hideout
Friday Update: Markets Now Pricing Fed Rate HIKES as Sta …
Traders Hideout
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
Rubios Good News Within Hours and the 30-Day Math: Why H …
Prediction Markets & Event Contracts
Beijing Summit Closes: Xi Pledges Hormuz Help -- $1.14B …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 2,947 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,860


you can remove the non decscending elements like this :


 
Code
int i;
            int flag;

            List<int> Both = new List<int>() { 1062, 1057, 1056, 1050, 1045, 1046, 1041, 1042, 1033, 1038, 1030 };

            i = Both.Count - 1;

            do
            {
                flag = 0;
                while (i > 0)
                {
                    if (Both[i] > Both[i - 1])
                    {
                        Both.RemoveAt(i);
                        flag = 1;
                    }
                    i--;
                }
            } while (flag == 1);

            foreach (int j in Both)
                  {
                        Print(j);
                  };


Follow me on X Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
victorg20013
Los Angeles
 
Posts: 11 since Feb 2017
Thanks Given: 3
Thanks Received: 0

Thanks!
Sometimes the count of the list changes, and the ints change.
Is there a way so that it does it for any range, and any numbers?
Because sometimes I won't know the values in the array.


Reply With Quote
  #5 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 2,947 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,860


victorg20013 View Post
Thanks!
Sometimes the count of the list changes, and the ints change.
Is there a way so that it does it for any range, and any numbers?
Because sometimes I won't know the values in the array.

it's just an example,
it will work for any series of numbers


Follow me on X Visit my NexusFi Trade Journal Reply With Quote




Last Updated on February 18, 2017


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts