Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Collect a list of values from different timeframe

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

    Collect a list of values from different timeframe

    I run my strategy on 900 tick chart. However, I want to store daily values of Open, High, Low and Close (without adding data series). I am able to get daily, but I don't want to have like 10 or 20 (x 4 for each open, high, low and close) variables.

    Can you provide me an example of using a list and adding to it once a day, which would trigger in within OnBarUpdate method and
    Code:
    if(Bars.IsFirstBarOfSession)
    calculation.

    Thanks.

    #2
    Hi UltraNIX, thanks for posting.

    If you run the strategy OnBarClose you can use the BarsInProgress index to track the close of each daily bar e.g.
    Code:
    //Class level
    public struct Prices {
    public Prices(double open, double high, double low, double close) { Close = close, High = high, Low = low, Close = close }
    
    public double Open { get; }
    public double High { get; }
    public double Low { get; }
    public double Close { get; }
    
    }
    
    Dictionary<int, Prices> MyDictionary = new Dictionary<int, Prices>();
    
    OnBarUpdate:
    
    if(BarsInProgress == 1) //daily series
        MyDictionary.Add(CurrentBars[1], new Prices(Opens[1][0], Highs[1][0], Lows[1][0], Close[1][0]));
    The Struct and Dictionary documentation are here:
    https://docs.microsoft.com/en-us/dot...n-types/struct
    https://docs.microsoft.com/en-us/dot...2?view=net-5.0
    Last edited by NinjaTrader_ChrisL; 09-21-2021, 10:23 AM.

    Comment


      #3
      I get an error at Coords part:
      Code:
       [TABLE="width: 724"]
      [TR]
      [TD][SIZE=14px][COLOR=black][FONT=Calibri]Method must have a return type[/FONT][/COLOR][/SIZE][/TD]
       		[/TR]
      [/TABLE]

      Comment


        #4
        Hi UltraNIX,

        I accidentally left the constructor as Coords, so i changed it to Prices.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        63 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        139 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X