Announcement

Collapse
No announcement yet.

daily data

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

  • daily data

    Hi all,

    I am working on a formula and I want to load the daily highs & lows for the last 300 days (minimum) into an array no matter what time frame my chart is. So I wrote a code similar to the one below:

    for (i=1; i<=299;i++) DailyHigh[i]=high(-i,getSymbol()+",D");

    My problem is if I did not load a Daily chart before (with at least 300 bars), or there are not 300 bars on the daily chart, the code stops at the above line and I can not go on further.

    I tried to put some checks like
    if (high(-i,getSymbol(),",D) ==null) {skip this step etc.}

    but they did not work.

    Any help on this?

    Thank you all in advance,

  • #2
    plucky
    Make sure that the Time Template is set to load the number of days you are requesting for that interval.
    To do this create a User Defined interval D and set it to load the # Days you want.
    Alex

    Comment


    • #3
      thank you Alexis for your reply,

      But is it not possible to do it without using the time templates?

      I just want to skip that part if the number of daily bars I can retrieve is less than 300.

      thanks

      Comment


      • #4
        plucky
        One way I can see to do this would be to check how many bars you have loaded for the symbol/interval using getOldestBarIndex(getSymbol()+",D") and then execute the code you want only if there is sufficient data.
        Alex

        Comment


        • #5
          Alexis,

          thank you very much for this. I will try it and let you know if it works.

          thanks again

          Comment


          • #6
            worked great Alexis,

            thank you again

            Comment

            Working...
            X