Announcement

Collapse
No announcement yet.

Simple MA backtesting questions

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

  • Simple MA backtesting questions

    Basic questions here... I'm using eSignal 7.4's supplied Simple MA sample efs script.

    1) It seems that the script produces trade signals based on a bar's closing price, but picks that same bar's entry price as the trade price. What am I missing?

    I have set up a time template for 2 days back, market hours. I chose a 5 minute interval for the chart. The equity is INTC. The date is 7/24/2003.

    The trade report shows a buy at 11:10 @ 24.78. The 11:10 bar does indeed close above the 10 period simple MA. No problem.

    The next few bars are all completely above the 10 period MA.

    The 11:30 bar opens at 24.85, has a high of 24.86, got as low as 24.73, and closes at 24.80 -- just below the 10 period simple MA. That should trigger the close.

    And indeed, the exit from that trade is listed at 11:30. But at 24.85. The 11:35 bar never gets close to 24.85...

    What gives?

    2) Assuming that problem is "fixed", how can one get real-time signals out of the same .efs? Ideally, popping up a trade window. Using the eSignal Paper Trade integrated broker for starters.

    3) Is there any way to get the OHLCV data for a bar in text form on a chart by clicking on it? (CyberTrader has this feature).

    4) How can I add code to that .efs to close out any open position at the end of the trading day? I'd expect the study object or the getValue method to have a time property, but it doesn't.

    Thanks in advance,
    Richard (obvious new user ;-)

  • #2
    Richard

    1) I am not sure which script you are referring to as some may also have similar scripts from prior versions but by what you describe it would appear that the strategy is set to Strategy.MARKET and Strategy.THISBAR.
    Strategy.MARKET means Buy/Sell at the Open which is clearly wrong if the signal is generated by a Close of a bar above/below the average.
    Open the efs with the Editor and check the lines where it says Strategy.doLong and Strategy.doShort.
    Change either Strategy.MARKET to Strategy.CLOSE or change Strategy.THISBAR to Strategy.NEXTBAR.
    In the first case you are instructing the Back Tester to use the Close of the bar that generates the signal and in the second the Open of the bar that follows the signal.
    If you then run the Back Test again you should now see that the trades occurr at the appropriate prices.

    2) You would need to add some code to generate visual signals (arrows, text, paint bars, etc) which are probably not in the efs now.

    3) I am not sure what you are asking here but the Cursor Window provides you with all the information relative to the bar the cursor is on at that time.

    4) You would add a couple more conditions one to close Long positions

    if(Strategy.isLong==true && (getHour()*100) + getMinute() ==1600)
    Strategy.doSell("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);

    and one to close Short positions

    if(Strategy.isShort==true && (getHour()*100) + getMinute() ==1600)
    Strategy.doCover("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);

    Hope this helps

    Alex
    Last edited by ACM; 07-24-2003, 09:04 PM.

    Comment


    • #3
      Alex,
      Thank you very much. Very helpful.

      The script I was referring to, straight from eSignal 7.3 and 7.4 is BtMovingAverage.efs. It has the bug exactly as you described. I've attached it for your use. Thanks for the fix. Hopefully 7.5 won't repeat this mistake.

      I'm not looking for a change on the chart itself. I want to get as close as possible to generating an "automatic order" with the paper trading integrated broker.

      Thanks again!
      Richard
      Attached Files

      Comment

      Working...
      X