Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamically Pulling A New Stock List Daily

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

    Dynamically Pulling A New Stock List Daily

    I am trying to build a bot that pulls the stocks with the biggest gains soon after trading starts. I haven't yet been able to get my bot to trade. So I am wondering if my code is even pulling the stocks, if I haven't subscribed to the correct live data feed, or if pulling a new stock list daily is even possible with your system.

    Here is the code I think should be pulling the data:

    AddDataSeries(Data.BarsPeriodType.Minute, 1); // Add a 1-minute data series


    // Calculate 30-day trading volume average
    double averageVolume = SUM(Volume, 30)[0] / 30.0;
    }
    }


    protected override void OnBarUpdate()
    {
    if (CurrentBar < 1)
    return;


    string symbol = Instrument.MasterInstrument.Name;


    double percentageIncrease = (Close[0] - Close[1]) / Close[1] * 100;


    if (stockIncreases.ContainsKey(symbol))
    {
    if (percentageIncrease > stockIncreases[symbol])
    stockIncreases[symbol] = percentageIncrease;
    }
    else
    {
    stockIncreases.Add(symbol, percentageIncrease);
    }


    double averageVolume = volumeSMA[0];
    double currentVolume = Volume[0];


    List<string> topStocks = stockIncreases.OrderByDescending(kv => kv.Value)
    .Take(10)
    .Select(kv => kv.Key)
    .ToList();


    foreach (string stock in topStocks)
    {
    if (!hasPurchasedAllQuarters && Time[0].TimeOfDay < new TimeSpan(9, 50, 0))
    {
    if (percentageIncrease >= 5.0 && averageVolume >= 500000 && currentVolume >= 125000)​


    Any help will be appreciated.
    Thanks​

    #2
    Hello WolfTrader9,

    Thank you for your post.

    What type of script is this and where is it being run in the platform? (e.g. indicator on a chart, market analyzer, SuperDOM, strategy, add-on, etc.) Do you receive any errors on the Log tab of the Control Center when you run this script?

    Ultimately, if you are unsure if your script is pulling stock data or if you don't have a data feed that offers the desired data, you should add prints to your script in order to debug and understand its behavior. We have another post that serves as a guide to using prints here:Based on the output from your print statements, this should help to see what is going on with different parts of your script and, if there is data, if it is being calculated as expected throughout. We have a data by provider grid that shows which providers support which types of data/instrument types here:I look forward to your reply.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    558 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X