Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Test of Prior day open and close

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

    Test of Prior day open and close

    Hi,
    trying to test for prior open and close of the previous day
    config section
    AddDataSeries(BarsPeriodType.Day, 1);

    OnBarUpdate secion
    if ( BarsinProgress ==1)
    {
    if ( Close[1] > Open[1]) PrevDayUp = 1; else PrevDayUp =0;
    }

    I've tried to search for another similar post but did not find.
    This never fires even though many days the bool is true

    My strategy needs to evaluate the previous open close each trading day
    So for example testing Aug 16-Aug 20, I on the 16 iteration it would look at trading day Aug 13 and on 17th look at Aug 16 open/close etc..
    Last edited by set2win; 08-25-2021, 10:23 AM.

    #2
    I found something that appears to work:
    if (sessionIterator == null)
    sessionIterator = new Data.SessionIterator(BarsArray[0]);

    // If the current data is not the same date as the current bar then its a new session
    if (currentDate != sessionIterator.GetTradingDay(Time[0]) && CurrentBars[1]>=0)
    {
    // The current day OHLC values are now the prior days value so set
    // them to their respect indicator series for plotting
    priorDayOpen = BarsArray[1].GetOpen(BarsArray[1].GetBar(Times[0][1]));
    priorDayHigh = BarsArray[1].GetHigh(BarsArray[1].GetBar(Times[0][1]));
    priorDayLow = BarsArray[1].GetLow(BarsArray[1].GetBar(Times[0][1]));
    priorDayClose = BarsArray[1].GetClose(BarsArray[1].GetBar(Times[0][1]));
    currentDate = sessionIterator.GetTradingDay(Time[0]);

    Hopefully it will work in real time as it does in historical.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    53 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X