Announcement

Collapse
No announcement yet.

Getting fills on studies other than default fills

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

  • Getting fills on studies other than default fills

    I noticed in the writeups that you can get your fills using commands like strategy.CLOSE and strategy.NEXTBAR to fill the order on the next bar's close for example. In reality none of the default strategy fills matches either my strategy or my experience in actual trading. From my database of actual orders, I have created a more accurate reflection of fills I expect to receive on orders. Is there a way to populate the backtesting of a study with my custom fills, rather than use the defaults?

    Thanks

    MonTrader

  • #2
    You can track the HIGH/LOW of the NEXTBAR and try to execute a LIMIT order in the back-testing routine...

    Lets say you identified a BUY signal at a closing price of $25 (on the previous bar).. Now, you would test the HIGH and LOW of the next bar for your expected entry price. If both the HIGH and LOW are within your expected entry price range, then you would execute a LIMIT order at the expected entry price.

    The code looks like ...

    PHP Code:
    var TradeTrigger  false;
    var 
    TradeDirection  0;
    var 
    ExpectedEntryPrice  0;

      if ((
    TradeTrigger) && (TradeDirection 0)) {
      
    //  Test for Bullish Entry Trigger
        
    if (low() > ExpectedEntryPrice) {
         
    //  price broke through our expected entry price
          
    Strategy.doLong("Long",Strategy.LIMITStrategy.THISBARStrategy.DEFAULT, open());
          
    TradeTrigger false;
        } else if (
    high() >= ExpectedEntryPrice) {
         
    //  Normal Fill
          
    Strategy.doLong("Long",Strategy.LIMITStrategy.THISBARStrategy.DEFAULT,ExpectedEntryPrice );
          
    TradeTrigger false;
        }
      }

      if ((
    TradeTrigger) && (TradeDirection 0)) {
      
    //  Test for Bullish Entry Trigger
        
    if (high() < ExpectedEntryPrice) {
         
    //  price broke through our expected entry price
          
    Strategy.doShort("Short",Strategy.LIMITStrategy.THISBARStrategy.DEFAULT, open());
          
    TradeTrigger false;
        } else if (
    low() <= ExpectedEntryPrice) {
         
    //  Normal Fill
          
    Strategy.doShort("Short",Strategy.LIMITStrategy.THISBARStrategy.DEFAULT,ExpectedEntryPrice );
          
    TradeTrigger false;
        }
      }


    if ((
    buy condition) && (!Strategy.isLong())) {
      
    TradeTrigger true;
      
    TradeDirection 1;  // bullish
      
    ExpectedEntryPrice close()+0.50;
    }
    if ((
    sell condition) && (!Strategy.isShort())) {
      
    TradeTrigger true;
      
    TradeDirection = -1;  // bearish
      
    ExpectedEntryPrice close()-0.50;

    By controling the ExpectedEntryPrice variable, you can attempt to force LIMIT orders that are closer to your expected entry levels..

    Hope this helps...

    B
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Not what I had in mind

      In your function, you are still using the standard strategy.LIMIT. I wanted to know if e-signal backtesting allows me to populate the database of trades with fills that I will calculate from my own algorithms that I feel are more realistic. For example, let's say that I measure conditions in the market and I've got a signal that going to go buy at 105.05. From my algorithm, I'm predicting I'll get a fair fill at 105.07 on this trade. I want to put into the backtesting data on that trade a fill at 105.07.

      Next trade, say the market has quieted down a bunch and I get another buy at 105.05, but my algorithm predicts a fill at 105.05. I want that fill to be put in at 105.05.

      Can you manipulate the fills on the backtesting at all or are you limited to just the strategy.CLOSE, strategy.LIMIT, etc. that come with e-Signal.

      Thanks,

      MonTrader

      Comment


      • #4
        Solution...

        Use the LIMIT order feature to FORCE in your expected fill price. The code I gave you allows you to FORCE in a LIMIT ORDER price (that could be ANYTHING). So all you need to do is use my code example and place your expected fill price into "ExpectedEntryPrice".

        The code should work perfectly....

        The only condition where your EXPECTED fill price may change is if the MARKET NEVER TRADES AT THAT PRICE. My code handles that and allows the system to enter at the OPEN - if this is the case.

        If you need more help, let me know.

        B
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          Perfect! I was a little dense on use of your routine

          I now understand completely and will integrate your routine into my study. Thanks so much!

          Comment

          Working...
          X