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.
    Chris L.NinjaTrader Customer Service

    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.

        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by proptradingshop, Yesterday, 11:30 AM
        9 responses
        29 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by NRITV, Today, 09:05 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by xiinteractive, Today, 08:29 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by DT215, 08-08-2023, 11:03 AM
        3 responses
        444 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by Thomas79, Today, 08:14 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X