Announcement

Collapse
No announcement yet.

compute on bar close

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

  • compute on bar close

    Hi,

    How can I force the efs to be computed at the end of each bar as oppose to at the beginning of the next bar?

    I have SetComputerOnClose(), it enforces the computation only once at the end of the bar, but that computation is only triggered at the first tick of the next bar.

    A simple solution would be to add one more bar to the timeframe. I'm just wondering if there is another way.

    Thank you in advance.

    W

  • #2
    you have to think in two modes of operation with working with complex efs scripts..

    a. Current bar (tick by tick)
    b. Historical bar (loaded and calced up to the "Current Bar".

    When writing your efs script, you want to handle "historical bars" as barIndex 0. This means close(0), high(0), low(0) and open(0). Everything is handled at the END OF THE BAR for Backtesting and other functions.

    For Current Bar, you have to wait for a new bar to form (with BarState or the Date Functions I use (below), then check the -1 bar (barIndex -1 : high(-1), open(-1)........)

    This gives you the ability to create an efs that can run backtests as well as operate in RT (tick by tick) combined.

    It's just a different way of doing things but it works.

    PHP Code:
    nLastRawTime null;
    BarCounter 0;

    function 
    main() {
       if ((
    getValue("rawtime"0) != nLastRawTime) ) {
         
    nLastRawTime getValue("rawtime"0);
         
    BarCounter += 1;
       }
        return;

    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      The issue is that the last bar of the current trading day will not be executed until the first tick of the first bar of tomorrow.

      Comment


      • #4
        are you trying to use the last bar of the day to get out of your trades or exit the backtest system's trades? If so, then there is another way to handle this.
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          Yes, that's right. Right now, I'm using an extra bar in addition to the end of the market trading session, so that my efs can execute and get out of a trade. I'm just wondering if there's a better way of doing it.

          W

          Comment

          Working...
          X