NexusFi: Find Your Edge


Home Menu

 





List to DataSeries


Discussion in NinjaTrader

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




 
Search this Thread

List to DataSeries

  #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?
Cheap historycal L1 data for stocks
Stocks and ETFs
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
REcommedations for programming help
Sierra Chart
NexusFi Journal Challenge - May 2024
Feedback and Announcements
 
  #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: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


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 Twitter 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: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


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 Twitter Visit my NexusFi Trade Journal Reply With Quote




Last Updated on February 18, 2017


© 2024 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 - Privacy Policy - Downloads - Top
no new posts