Problems with TimeFrame. How do I make this program?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #243350 quote
    RivusNiger
    Participant
    New

    Hello,

    I’ve been programming for a short time and I’ve run into a problem. The thing is that I want to make a program that scans a list of stocks for 250 days. On each of those days it finds the opening price of the day and also the share price at a given hour and at another given hour, data that will then be processed.

    The intention is to make a screener that calculates the percentage by which a stock at a given hour (H1) exceeded the indicated % (perH1) with respect to the opening of the day (opening),and at another indicated hour (H2) it was below another indicated percentage (perH2) (with respect to the opening price).

    I have written this program but I don’t think it works well. I suppose the problem is that the TIMEFRAMES are not nested. I need the program to access the hours of each of the days. How do I do this?

    H1=1 //First check: hour after start of session
    perH1=0.5// First check: percentage of change from opening
    
    H2=7 // Second check: hour after start of session
    perH2=0 // Second check: percentage of change from opening
    
    dayss=250  // analysed period
    
    c1=close>0
    
    totalCases=0
    
    For i = 0 to dayss-1
    
      TIMEFRAME(daily)
      opening=open[i]
    
      TIMEFRAME(1 hour)
      priceControl1=close[8-H1]
      variationControl1= ((priceControl1-opening)/opening)*100
    
      priceControl2=close[8-H2]
      variationControl2= ((priceControl2-opening)/opening)*100
    
      if variationControl1 >= perH1 and variationControl2 <= perH2 then
       totalCases=totalCases+1
      endif
    
    next
    
    percentage=(totalCases/dayss)*100
    
    SCREENER[c1](percentage as "% Cases")

     

     

     

    Thanks!

    #243390 quote
    robertogozzi
    Moderator
    Master

    What you want to achieve is not possible.

    Timeframe shouldn’t be use inside loops or IF blocks.

    In addition, when you loop 250 bars backwards on the hourly TF, it’s just slightly over 10 days, not much!!!

    Iván González thanked this post
    #243392 quote
    robertogozzi
    Moderator
    Master

    Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.

    Thanks 🙂

    #243409 quote
    RivusNiger
    Participant
    New

    My intention was actually to go through the last 250 days and take data from specific hourly bars each day and then process de data.
    How would you do it? Is it possible? Thanks for your answer.

    #243415 quote
    robertogozzi
    Moderator
    Master

    You can only go backwards roughly 10 days.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Problems with TimeFrame. How do I make this program?


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
RivusNiger @rivusniger Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by robertogozzi
1 year, 1 month ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 02/02/2025
Status: Active
Attachments: No files
Logo Logo
Loading...