Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position.Quantity

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

    Position.Quantity

    When backtesting and using trade sizes of 200 shares. Using Postions[0].Quantity as I am below, is this calculating if less than 200 shares have been entered over the life of the backtest so far or is it just calculating if less than 200 shares are currently open?

    bool enterTrade = false;

    if (Positions[0].Quantity < 200)
    {
    enterTrade = true;
    }
    else
    {
    enterTrade = BarsSinceEntry(0, "", 0) > 2;
    }

    if(enterTrade)
    {
    //conditions
    }
    Last edited by zachj; 10-07-2013, 08:02 PM.

    #2
    zachj, the Position object will give you access to the current strategy market position, however you would monitor it for each OnBarUpdate() I suppose, so you would just iterate through the backtest bars by processing it there.

    Comment


      #3
      What I'm trying to figure out is with the script I posted in initial post, when I have if (Positions[0].Quantity < 200) enterTrade otherwise BarsSinceEntry(0, "", 0) > 2; If i'm using 5min bars as primary(but BIP is on 1min) shouldn't this stop a trade from occuring 1minute later? The goal is to require 10min pass between trades. The trade data from SA below shows trades 1min apart. Is this a matter of OnExecution being required? That way it will update the data(200 shares traded) when trade is executed instead of 5min later after primary bar is closed.

      Instrument Entry price Exit price Entry time Exit time
      SCTY 39.73 38.54 6/5/2013 9:51 AM 6/5/2013 9:55 AM
      SCTY 39.7 38.51 6/5/2013 9:52 AM 6/5/2013 9:55 AM

      Note: I can't use (Performance.AllTrades.Count < 1) because I'm using multi instrument script.
      Last edited by zachj; 10-08-2013, 07:29 PM.

      Comment


        #4
        zachj, best would be bringing in the actual execution time and then ensure for any new signal seen on the 1 min that the current time would be higher than previous execution time + 10 for your signals. Generally your BarsSinceEntry will report based on the primary series for each instrument - from which BarsInProgress were you evaluating the first posted snippet? I would add in debug prints to exactly see which condition part leads to your unexpected entry.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        596 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        556 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        554 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X