Announcement

Collapse
No announcement yet.

When is "main()" called?

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

  • When is "main()" called?

    Question 1: The eSignal doc says that "main() will be called every time the Advanced chart receives a new trade". However, it seems to me that it's only called when the new trade happens at a different price. For example, I can see on the dome that multiple trades are happening at the same price, but main() is only being called once, and it's only being called for the first trade at that price. Is this true?

    Question 2: If so, this can cause some confusion when using changes in "volume()" to try to decide how much volume has occurred at different price levels. For example:

    1. A trade is done on a new bar at 1452.00 for 3 contracts. The EFS is called, and volume() returns 3.

    2. Additional trades are done at 1452.00 for an additional 500 contracts. The EFS is not called.

    3. A trade is done at 1452.25 for 5 contracts. The EFS is called. volume() reports 508 contracts. This includes the initial 3 contracts (already reported to the EFS), the additional 500 contracts at 1452.00, and the 5 contracts done at 1452.25.

    Is above the way it happens? If so, it seems that the EFS needs to use "getMostRecentTradeSize()" to determine how many of the volume() contracts were done at the new price, and allocate the rest of the volume() difference to the previous price. Is this right?

  • #2
    almerger
    To my knowledge an efs executes on every trade except with some electronically traded futures (such as ES or NQ) in which case it executes only when
    - Current trade price is different than the previous trade price.
    - Current trade price is at the bid and previous trade was at the ask or vice versa. The two trade prices can be the same in this instance.
    With tick based charts (Tick, Volume, Seconds, Price-change or Range) instead an efs executes on every trade even with those symbols.
    Alex

    Comment


    • #3
      I was using ES on a 5-minute chart. I'll try tick chart tomorrow. Thanks.

      Comment


      • #4
        Tick chart is the way to go, don't have to use volume() at all, getMostRecentTrade() covers it all. Thanks!

        Comment


        • #5
          On a non-tick chart, I'm using "volume()" to get the number of contracts that have been traded on ES since the beginning of the current bar.

          Here's the problem: how do you get the volume on contracts that were traded in the previous bar after the last invocation of EFS?

          For example, you could have this:
          Bar 3: buy 2 lots at 1235.00. EFS gets called, volume() = 2.
          Bar 3: buy 500 more lots at 1235.00. EFS does not get called.
          Bar 4: buy 5 lots at 1235.25. EFS gets called, volume() = 5.

          How do you find out about the 500 lots?
          Last edited by almerger; 04-09-2007, 06:02 AM.

          Comment


          • #6
            Oh wait (sheepish). I can give volume() a bar index. Sorry!

            Comment

            Working...
            X