Announcement

Collapse
No announcement yet.

Today's opening price

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

  • Today's opening price

    hi, is there anyway to get todays opening price and apply it to the callback stream from main? I would like to apply todays open to the processing of all bars. If there is a property or method I can get inside of preMain that would be great, like:

    var gTOP;
    preMain( )
    {
    // get Todays Opening Price, just for today
    gTOP = SomehowGetTodaysOpeningPrice( );
    }

    main( )
    {
    // do things here that apply gTOP to all bars we process
    return result
    }

    thanks, I appreciate any insights -mark

  • #2
    Well here is a suggestion on one way to do it. I'm not sure it is the most efficient, other's may have better methods...

    1) In main(), place a statemet at the top

    var nIndex = getCurrentBarIndex();
    if (nIndex == 0 && bFirstPass == false){ //Only do once
    set bFirstPass = true;
    var vDate = getValue("time"); // Not this can be expensive
    var vTodayBar = getFirstIndexofDay(vDate);
    nOpenPrice = getValueAbsolute("Open", vTodayBar); // Current Days open
    }

    if (bFirstPass == true) {
    <Place all your code inside this if statement>
    }

    2) Outside of both main and preMain()

    var bFirstPass = false;
    var nOpenPrice = null;


    The above **SHOULD** (haven't tested it) allow all the bars to interate without doing anything until the last (most current) bar is iterated. It will then get the open for the day.
    Garth

    Comment


    • #3
      Hi,

      Sorry, I just realized I only gave you 1/2 of the entire thought. Now that all historical bars have been interated, you can access them by calling close(), open(), high(), low(), etc.

      You can use getOldestBarIndex() to grab the oldest bar on the chart.

      So in theory you could create a loop like:

      nOldestIndex = getOldestBarIndex();

      for (i = nOldestIndex; i == 0; i++){
      }

      to interate through the historical data.

      G
      Garth

      Comment


      • #4
        Re: Reply to post 'Today's opening price'

        you could also figure out how many bars have traded today so far, call that
        X, then retrieve the open of bar -x.

        ----- Original Message -----
        From: <[email protected]>
        To: <[email protected]>
        Sent: Sunday, January 19, 2003 1:12 PM
        Subject: Reply to post 'Today's opening price'


        > Hello dloomis,
        >
        > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        >

        Comment


        • #5
          hi, as it is I have to hard-code my opening day price in preMain. Then, I use that value in my main( ) processing and it works fine.
          But...Im trying to avoid this hard-coding.

          Im trying these ideas, and learning alot in the process...thanks for the ideas and code!

          Comment


          • #6
            Re: Reply to post 'Today's opening price'

            It looked like Garth posted some sample code for this. We're going to be
            improving this in 7.3 and 7.4, making it easier to get those prices.

            m.

            --- [email protected] wrote:
            > Hello mattgundersen,
            >
            > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            >
            Matt Gundersen

            Comment


            • #7
              Re: Reply to post 'Today's opening price'

              It looked like Garth posted some sample code for this. We're going to be
              improving this in 7.3 and 7.4, making it easier to get those prices.

              m.

              --- [email protected] wrote:
              > Hello mattgundersen,
              >
              > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              >
              Matt Gundersen

              Comment


              • #8
                hi, thanks! that sounds interesting! Where may I find such sample code? My searches have turned up empty thus far.

                Comment

                Working...
                X