Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trying to get 2DaysAgo High and Low

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

    Trying to get 2DaysAgo High and Low

    Hi Everyone, I am writing a script to get 2DaysAgo high and low, in order to use it to draw horizontal lines. I have tried many options, but still not success, any suggestions, see my code below. Thanks in advance. // Calculate the High and Low of 2DaysAgo
    double high2DaysAgo = PriorDayOHLC().PriorHigh[2];
    double low2DaysAgo = PriorDayOHLC().PriorLow[2];


    // Draw a horizontal line for the high of 2DaysAgo
    Draw.HorizontalLine(this, "high2DaysAgo", high2DaysAgo, Brushes.Red);
    // Text box positioning (adjust as needed)
    int xPosition17 = 5; // Adjust X-axis offset
    int yPosition17= (int)high2DaysAgo- 0; // Adjust Y-axis offset relative to line
    // Text box content
    string labelText17 = "2 Days Ago's High Liqudity"; // Replace with your desired label
    // Draw the text box
    Draw.Text(this, "TextOverlay17", labelText17, xPosition17, yPosition17, Brushes.White);


    // Draw a horizontal line for the low of 2DaysAgo
    Draw.HorizontalLine(this, "low2DaysAgo", low2DaysAgo, Brushes.Green);
    // Text box positioning (adjust as needed)
    int xPosition18 = 5; // Adjust X-axis offset
    int yPosition18= (int)low2DaysAgo- 0; // Adjust Y-axis offset relative to line
    // Text box content
    string labelText18 = "2 Days Ago's Low Liqudity"; // Replace with your desired label
    // Draw the text box
    Draw.Text(this, "TextOverlay18", labelText18, xPosition18, yPosition18, Brushes.White);​

    #2
    Hello profedet,

    Thank you for your post.

    What is the data series you are running this strategy on?

    The way the indexing works for the PriorDayOHLC indicator depends on the input series.

    For example, if you have a minute chart and it's the middle of the day, both PriorDayOHLC.PriorHigh[0] and PriorDayOHLC.PriorHigh[2] would give the same value because both the current bar from the minute series and 2 bars ago on that minute series have the same prior day high value.

    You could instead use PriorDayOHLC.PriorHigh[Bars.BarsSinceNewTradingDay + 1] to get the PriorDayOHLC values from 2 days ago.



    Please let us know if you have any further questions.​

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    557 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