Announcement

Collapse
No announcement yet.

Is Strategy function work like OCA Group and what is the live time of order ?

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

  • Is Strategy function work like OCA Group and what is the live time of order ?

    hi,

    1) Is Strategy function work like OCA Group on a bar ?

    2) if for exemple, Im not fill, should i place again the order for the next bar or ?

    as Order on next bar are cancelled, or will stay alive until ?

    thanks,
    regards,

  • #2
    Strategy Functions..

    For "Strategy" (Backtesting) functions, an order is valid for THISBAR or NEXTBAR (depending on when parameter you select).

    If you place a MARKET order for NEXTBAR - it will always fill the order.

    If you place a LIMIT order to THISBAR, then you should check the price action of the bar to determine if the order was allowed to be filled.

    I assume, you could check Strategy.isLong() or Strategy.isShort() to determine if your order was placed. But I always check the price action of the bar I'm trying to enter on to determine if my order is able to be filled. For example..

    LongEntryPrice = low(-3)-0.50;

    if ((low() < LongEntryPrice) && (!Strategy.isLong())) {
    Strategy.doLong("Long Limit Order", Strategy.LIMIT, Strategy.THISBAR, Strategy.DEFAULT, LongEntryPrice);
    }
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Is Strategy function work like OCA Group and what is the live time of order ?

      hi,

      I want to know, if Strategy function for back testing work like OCA Group ?
      As if i place a buy and a sell order, with strategy.STOP and strategy.NEXTBAR, then if one is FILLED, is the other pending order automaticly cancelled, or ?

      thanks,
      regards,

      Comment


      • #4
        No...

        The Stragegy functions work like this...

        If you place a BUY order for NEXTBAR, then that order is only valid on the next bar (In backtest mode)..

        If you place a BUY MARKET order for NEXTBAR, then it will automatically FILL the order at the OPEN PRICE of the next bar.

        If you place a BUY LIMIT order for NEXTBAR, then the order will only FILL if the next bar trades in a range that will allow to FILL this order. This is why I normally track the RANGE of any subsequent bar to determine if we can get filled or not.

        For example, if I wanted to place a BUY LIMIT order at $35 and the stock was trading at $36 - there is not chance that I can get filled. So, I would record the projected trade direction and price, then track the market price till I GOT FILLED or A NEW TRIGGER FORMED (that may change the entry status). Like this..

        PHP Code:
        //  Establish Entry Trigger Patterns and conditions.
        if ((buy_trigger) && (!Strategy.isLong())) {
          
        TradeDirection 1//  bullish
          
        TradeEntryPrice close();  //  lets assume $35.00
        }

        if ((
        sell_trigger) && (!Strategy.isShort())) {
          
        TradeDirection = -1//  bearish
          
        TradeEntryPrice close();  //  lets assume $33.00
        }

        //  Test for Established Entry Trigger Orders to be filled.
         
        if (TradeDirection != 0) {
           if ((
        TradeDirection 0) && ((low() <= TradeEntryPrice))) {  // bullish trigger
             
        if (open() <= TradeEntryPrice) { // possible GAP below entry price
               
        Strategy.doLong("Le Open"Strategy.MARKETStrategy.THISBAR);
             } else { 
        // Assume entry at limit price
               
        Strategy.doLong("Le Lmt"Strategy.LIMITStrategy.THISBARStrategy.DEFAULT, TradeEntryPrice);
             }
            
        TradeDirection 0//  Neutral
            
        TradeEntryPrice null;  //  nothing
           
        }

           if ((
        TradeDirection 0) && ((high() >= TradeEntryPrice))) {  // bullish trigger
             
        if (open() >= TradeEntryPrice) { // possible GAP above entry price
               
        Strategy.doShort("Se Open"Strategy.MARKETStrategy.THISBAR);
             } else { 
        // Assume entry at limit price
               
        Strategy.doShort("Se Lmt"Strategy.LIMITStrategy.THISBARStrategy.DEFAULT, TradeEntryPrice);
             }
            
        TradeDirection 0//  Neutral
            
        TradeEntryPrice null;  //  nothing
           
        }

         } 
        Hope this helps. The bottom line is I've always found it easier to CODE my system to track everything than assume something is going to happen the want I want it to.
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment

        Working...
        X