Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Printing time that is associated with a historical bar list

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

    Printing time that is associated with a historical bar list

    In case I answer this I think it will be beneficial for anyone in the future to know.

    I am saving important bars into a list and then trying to print the time value associate with those bars. Using Print(string.Format(Time[Barnumber_Low[count]]) will not work because this will print the bars ago function. So I am looking for a way to print the bars associated with the stored bar number. If I figure this out I will post it here.

    #2
    Okay so I have a few sections. The low and the high lists are identical except for the name.

    //if Current trading day not equal to previous trading day. Clear the bar list
    if(Daily_inquiry != New_Tradingday.GetTradingDay(Time[0]) || Daily_inquiry == null)
    {
    //count = 0;
    Barnumber_High.Clear();
    Barnumber_Low.Clear();
    Low_Time_stamps.Clear();
    High_Time_stamps.Clear();
    Daily_inquiry = New_Tradingday.GetTradingDay(Time[0]);
    }


    //stores current bar for future comparisons
    Barnumber_High.Add(CurrentBar);
    High_Time_stamps.Add(Time[0]);

    //prints every value in the list
    for(int count = 0; count < Barnumber_High.Count; count++)
    {
    Print(string.Format("Possible high occurs at bar number " + Barnumber_High[count] + " which occurs on " + High_Time_stamps[count] ));
    }​​​

    Comment


      #3
      Hello RISKYBUSINEZZ,

      Thanks for your post.

      CurrentBar would be used to get the current forming bar on the chart. Time[0] would be used to get the current time of the current bar on the chart.

      See the help guide documentation below for more information and sample code.
      CurrentBar: https://ninjatrader.com/support/help...currentbar.htm
      Time[0]: https://ninjatrader.com/support/help...eries_time.htm

      Unfortunately, using Lists in a custom NinjaScript falls under C# education which goes beyond the level of support we would be able to provide you with. To find educational information about using Lists in C#, you could do a quick Google search for something like 'using Lists in C#'.

      Otherwise, this forum thread will be open for other community members to share their insights on this topic.

      Let me know if I may assist further.
      Brandon H.NinjaTrader Customer Service

      Comment


        #4
        Yes, no worries. So the best way to store these values is to get Time[#] for the bar you need and store it as it is occurring in a list that is indexed at the same time you store the bar. In my case I had to adjust it to Time[#] to do some logic on the candles before storing the value.

        So basically information stored in lists is the way to go for sure. I managed to get it working. I'll try and post the full code later.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rocketman7, Today, 02:12 AM
        0 responses
        3 views
        0 likes
        Last Post rocketman7  
        Started by dustydbayer, Today, 01:59 AM
        0 responses
        1 view
        0 likes
        Last Post dustydbayer  
        Started by inanazsocial, Today, 01:15 AM
        0 responses
        4 views
        0 likes
        Last Post inanazsocial  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        5 responses
        22 views
        0 likes
        Last Post trilliantrader  
        Started by Davidtowleii, Today, 12:15 AM
        0 responses
        3 views
        0 likes
        Last Post Davidtowleii  
        Working...
        X