Announcement

Collapse
No announcement yet.

Coding pitfalls

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

  • Coding pitfalls

    Hi Clearpicks
    Here are a few remarks about problems with eSignal coding:
    - Backtesting Tick charts using Candles is not reliable because these charts do not display historic candle values in a consistent way. It depends where the chart begins. Not clear to me how this works, but my algorithm is based on candle values and so tick chart backtesting is worthless.
    - Backtesting runs only once per bar, but in real time, the efs runs roughly every tick, so if you have a stop loss in the middle of a bar, the closing trade will happen at the open of the next bar for example in backtest, but at market (if you coded so) in real time. This might be a big problem in a longer time chart, ex on AB 10 minutes or more.
    - Backtesting for a defined period, for example from Jan 1 to Feb 1 is not possible, or at least I do not know how to do it. You can run a test for several months back, and retrieve the results for the desired period, but this is done manual, and so it is inconvenient.
    - The API for InteractiveBrokers is barebones, just the minimum.
    No Acknowledgment of function return, no info of values of trade executed or of contracts still open, no info about the Internet connection with eSignal or with InteractiveBrokers etc.
    - Another major deficiency is the inability to run simultaneously the same efs on different charts, with different securities and different time periods.
    Or to run in parallel/simultaneous different efs' on different charts but where the efs' might have the same Global variables. Specifically, I refer to a case where I wrote an efs to run on YM and then adapt it to run on ES and another one to run on AB, with different offset values. Each efs has its own name but in fact most of the code and it's globals are identical.
    This is very disappointing and it might push me to move to TradeStation.
    I might be wrong on some of these points, coming from a lack of solid knowledge of esignal coding, and so I would be grateful to be corrected by somebody more knowledgeable.
    Arie

  • #2
    Arie
    Here are a few considerations on some of the remarks you make.

    - Backtesting runs only once per bar, but in real time, the efs runs roughly every tick, so if you have a stop loss in the middle of a bar, the closing trade will happen at the open of the next bar for example in backtest, but at market (if you coded so) in real time

    That depends on how you write the trading/back testing code. You can use Strategy.STOP and Strategy.LIMIT also in back testing and it will enter/exit trades at the defined price even if this is an intrabar price. You should find several examples in this Bulletin Board showing how to do this.

    - Backtesting for a defined period, for example from Jan 1 to Feb 1 is not possible, or at least I do not know how to do it.

    This is easily resolved with a few lines of code. See this post for an example.

    As to the global variables you can make them unique by adding for example the symbol and interval of the chart in which the efs is running.
    Alex

    Comment


    • #3
      Re: Coding pitfalls

      Hi Arie,

      Thanks for all the information. I have not got time to play with those APIs yet.

      I have one quick comment on your statement. If your algorithm/backtesting results highly rely on the starting point where the tick candles are built, your system might be too sensitive, in another word, not robust enough. Statistically the backtesting results (I am refering to the returns, drawdowns, etc, not the exact enter/exit signals) over a long time period should be (almost) the same no matter where the charts begin. If your backtesting results varies erratically on tick charts, you'd better watch out and check your algotithm seriously. This is just some quick thought based on my engineering background.

      -- Clearpicks

      Originally posted by arieal
      Hi Clearpicks
      Here are a few remarks about problems with eSignal coding:
      - Backtesting Tick charts using Candles is not reliable because these charts do not display historic candle values in a consistent way. It depends where the chart begins. Not clear to me how this works, but my algorithm is based on candle values and so tick chart backtesting is worthless.
      - Backtesting runs only once per bar, but in real time, the efs runs roughly every tick, so if you have a stop loss in the middle of a bar, the closing trade will happen at the open of the next bar for example in backtest, but at market (if you coded so) in real time. This might be a big problem in a longer time chart, ex on AB 10 minutes or more.
      - Backtesting for a defined period, for example from Jan 1 to Feb 1 is not possible, or at least I do not know how to do it. You can run a test for several months back, and retrieve the results for the desired period, but this is done manual, and so it is inconvenient.
      - The API for InteractiveBrokers is barebones, just the minimum.
      No Acknowledgment of function return, no info of values of trade executed or of contracts still open, no info about the Internet connection with eSignal or with InteractiveBrokers etc.
      - Another major deficiency is the inability to run simultaneously the same efs on different charts, with different securities and different time periods.
      Or to run in parallel/simultaneous different efs' on different charts but where the efs' might have the same Global variables. Specifically, I refer to a case where I wrote an efs to run on YM and then adapt it to run on ES and another one to run on AB, with different offset values. Each efs has its own name but in fact most of the code and it's globals are identical.
      This is very disappointing and it might push me to move to TradeStation.
      I might be wrong on some of these points, coming from a lack of solid knowledge of esignal coding, and so I would be grateful to be corrected by somebody more knowledgeable.
      Arie

      Comment


      • #4
        Robust Algorithm

        Hi Clearpicks

        34. I am aware of this slogan of having a robust algorithm.

        - I have a simple Crossover algorithm using some custom indicator.
        - The results are best on a 10 min AB chart, and not bad on other 10 min futures or on Tick charts.
        - These results, not bad at all on an annual base (margin/profit), are comparable or better to CTA's results published in Futures magazine.
        - While this might look nice and dandy on paper, there are still two problems:

        a. I need to overcome the Psychological problem of taking Every trade given by the system, this includes taking every Start and End of Day time.
        In my case the optimum is at 10 am for start, but some days at 10 am there is already a trend underway, and I am gambling not to start because it's too late. Sometimes I am right, but... you know the rest. You cannot out-smart a mechanical system.

        b. The margin of error is very small.
        If I do not take a trade which might turn into a big winner/loser, this might change drastically the results.
        This is specially true on a Tick chart, and that's what I ment when I mentioned the lack of Backtesting Reliability for Tick charts.
        On a 10 min chart, the tests give always the same results, for the same parameters and the same timeframes.

        So, speaking about system robustness:
        - first, I am talking about an Intraday system not a Long term where the indicators are more reliable.
        - second, I do not see the famous CTA's with their robust and diversifyied systems doing much better than me.

        The best CTA's bust on average of much less than 50% annual returns, with big, big drawdowns and losing years, and small Sharpe factors.

        Sure, I work towards diversifying my trade in terms of securities and time frames, but am still bothered by this thought: why are those CTA's not doing much better?
        Arie

        Comment

        Working...
        X