Announcement

Collapse
No announcement yet.

Help! I'm stuck.

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

  • Help! I'm stuck.

    I am trying to implement the following strategy in a backtest. Please tell me if it can be done with eSignal and/or point me to an example.
    Thanks
    The major points and questions are:
    1] A new long position is entered every day if an entry limit price is touched
    2] Each position can remain open for as long as 5 days if not closed on the first
    day, so possibly 6 positions can be open simultaneously.
    3] How do I test for contract age?
    4] Must any backtest control parameters be re-set for the test?

    -------------start of strategy pseudo-code
    if(touched contract entry limit price X)
    {
    Strategy.doLong(...buy at limit price X...);
    if(made a profit at the close that day)
    {
    Strategy.doSell(..sell that same day at the close..);
    }
    else
    {
    if(contract age <= 5 days)
    {
    if(high >= entry price X)
    {
    Strategy.doSell(...exit at entry price X...);
    }
    }
    else
    {
    Strategy.doSell(...sell 6th day at close if did not recover to buy price...);
    }
    }
    }

  • #2
    How do I retrieve the number of days a position has been open?

    How do I retrieve the number of days (I am using daily bars) a position has been open? I suspect it is something like "get position age". So far I have not been able to find it at Central Support.

    Comment


    • #3
      Help! I'm stuck.

      I have spent many hours on this with no success. I have been trying to use Date arithmetic to implement testing for contract age. If there is an example to which I can refer please point me to it.

      Also it will help me enormously to know if the backtester can even do what I want it to do [ie] keep track of multiple position and exit each if a specified maximum number of bars [days] pass after opening the position. Otherwise I will be wasting a lot of time.

      I am using daily bars.

      Comment


      • #4
        Hi Joe,

        Since you are looking at back-testing, the use of the date object for any calculation must not use the actual time from the System clock. Rather, you must use the bar time from the eSignal bars.

        To keep track of the number of days a position is in a trade with each bar equals a day, if in a trade, add one to a variable that represents number of days in a trade. If using an interval less than a day, use the built in day() function and iterate the variable each time the value returned changes.

        As far as the backtester and keeping track of multiple positions, I do not believe it is possible to keep track of which one is entered and exited. See this link

        Comment


        • #5
          Many thanks Steve,

          Much appreciated. That broke the log jam.

          The link to the code written by the Australian gentleman will probably be useful too.

          Regarding multiple positions, do you think the following might work?
          Create and maintain a table of positions [a new position is entered each day]. One row for each bar, or day because I am using daily bars.

          Entered into each row would be exit price goal. The table would be checked every day for exit price goal touched or days in position > 5 days [ie] for each row, if exit price is touched or 5 days exceeded then the position is closed and row entries cleared. Each day we know that that the row entry 5 rows back is the one which has expired if it is still open.

          Is bar time from the eSignal bars obtainable with a built-in function?.

          Comment


          • #6
            Hi Joe,

            You are most welcome, good to hear that helped.

            Regarding eSignal commands that can be used for bar-time, most of the date object properties have matching eSignal commands (i.e. functions aka methods).

            Here is a link to my FileShare, where there is a folder entitled Time. In this folder, there is an efs that demonstrates the different ways to access the date object and the cooresponding efs methods. The file name is Time_Functions_12_27_2006.efs and when you run it, the output will go to a file, which should be accessable via a button on the screen. I believe this will answer your questions. I haven't run this in a while, so if you have any problems accessing the efs output please let me know.

            As far as the table is concerned, that sounds like a good idea.

            Comment


            • #7
              Boy, did all that help. My enthusiasm is re-kindled.

              Thanks for the "Time_Functions_12_27_2006.efs" link. I was able to easily navigate to it and access it - so your link access design still works.

              Bless you, you're a jolly good fellow.

              Comment

              Working...
              X