Announcement

Collapse
No announcement yet.

LIMIT strategy question

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

  • LIMIT strategy question

    It is a shame that the documents listed by JasonK as an introduction to the back tester don't actually appear in the kb - in fact the back tester doesn't seem to be in there much at all...

    anyway....

    when using the LIMIT strategy is it safe to assume that the analyzer only fills you at the limit price if in fact it was possible at that bar? Or does it fill you at the limit you specify regardless of possibility?

    Thanks in advance...

  • #2
    mitboy,

    I just did a quick test using the following code which enters on the second bar of a chart.

    PHP Code:
    var bInit false;
    function 
    main() 
    {
        if(!
    bInit && getBarState() != BARSTATE_ALLBARS)
        {
            
    Strategy.doLong("test entry"Strategy.MARKETStrategy.THISBAR100);
            
    Strategy.doSell("sell limit"Strategy.LIMITStrategy.THISBAR1002000.00);
            
            
    bInit true;
        }

    When I ran the backtester it entered on the open of the second bar, but didn't exit until the last bar of the chart. (I had close trades at end of back test checked)

    So my limit price of $2,000.00 wasn't hit on the $40 stock I was testing with.

    Changing the limit to a value that was hit later, but not on THISBAR also resulted in the trade being closed on the last bar.

    Changing it to a value that was hit by the second bar resulted in the trade being closed on the second bar at the limit price.

    It looks like if you're not filled on the bar you specify, the limit order is thrown away. So you need to check if the price hits or exceeds your limit price before putting in a limit order. Using Strategy.THISBAR is like placing a day only order with your broker. Either it gets filled today, or it gets cancelled at the end of the day.

    There isn't a good 'til cancelled order type when using the Strategy object.


    Steve

    Comment


    • #3
      hey Steve,
      thanks for that - I had my reasons to suspect that something would be restricting the price entry!

      Comment

      Working...
      X