I just completed coding of my strategy and started coding the position buy/sell section and am running into problems I would appreciate if somebody could provide a clue on?
Essentially, I'm looping through the bars, whenever my strategy gives me a long trigger and I don't have any active positions, I'm executing a BuyAtStop for the next bar and at the same time execute a SellAtStop also fo rthe next bar to limit my losses in case things are going the other way than anticipated. Same for a short trigger where I'm using the ShortAtStop combined with a CoverAtStop.
If I have active positions, I'm trying to sell(SellAtLimit)/cover(CoverAtLimit) 50% of that position at the first resistance level and the rest at the next resistance level.
Per the debug log section below, I am getting the first long trigger point of my back-testing on bar 70 but then my position count starts increasing- i.e. I thought the way I coded this (see code sections below) I would only have max. 1 position open. Also, I am runing this in Raw Profit Mode with 100 shares but when I check the Trades I see all kind of number of hsares but the 100 shares. For example for the 1st execution date on 6/18/09 I am getting 16 Trade entries, 9 of which show an entry date but are still open - i.e. no exit date but show quantity 0, the remaining entries show starnge numbers in the quantity column (like 2, 50, 3, 13, etc.)
Again, any help is greatly appreciated...
QUOTE:
Bar = 65 Last Position NOT active Total Positions = 0
Bar = 66 Last Position NOT active Total Positions = 0
Bar = 67 Last Position NOT active Total Positions = 0
Bar = 68 Last Position NOT active Total Positions = 0
Bar = 69 Last Position NOT active Total Positions = 0
Bar = 70 Last Position NOT active Total Positions = 0
Bar = 70 L=71 S=0 Long BuyAtStop $10.5 6/18/2009 12:00:00 AM
Bar = 71 Last Position Active Total Positions = 1
Bar = 71 L=71 S=0 Fail Long SellAtLimit $12.26 6/17/2009 12:00:00 AM
Bar = 72 Last Position Active Total Positions = 2
Bar = 72 L=71 S=0 Fail Long SellAtLimit $12.26 6/18/2009 12:00:00 AM
Bar = 73 Last Position Active Total Positions = 3
Bar = 73 L=71 S=0 Fail Long SellAtLimit $11.01 6/19/2009 12:00:00 AM
Bar = 74 Last Position Active Total Positions = 4
Bar = 74 L=71 S=0 Fail Long SellAtLimit $11.01 6/22/2009 12:00:00 AM
Bar = 75 Last Position Active Total Positions = 5
Bar = 75 L=71 S=0 Fail Long SellAtLimit $11.01 6/23/2009 12:00:00 AM
Bar = 76 Last Position Active Total Positions = 6
Bar = 76 L=71 S=0 Fail Long SellAtLimit $11.01 6/24/2009 12:00:00 AM
Bar = 77 Last Position Active Total Positions = 7
Bar = 77 L=71 S=0 Fail Long SellAtLimit $11.01 6/25/2009 12:00:00 AM
Bar = 78 Last Position Active Total Positions = 8
Bar = 78 L=71 S=0 Fail Long SellAtLimit $10.72 6/26/2009 12:00:00 AM
Bar = 79 Last Position Active Total Positions = 9
Bar = 79 L=71 S=0 Fail Long SellAtLimit $10.72 6/29/2009 12:00:00 AM
Bar = 80 Last Position Active Total Positions = 10
Bar = 80 L=71 S=0 Fail Long SellAtLimit $10.72 6/30/2009 12:00:00 AM
Bar = 81 Last Position Active Total Positions = 11
Bar = 81 L=71 S=0 Fail Long SellAtLimit $10.38115 7/1/2009 12:00:00 AM
Bar = 82 Last Position Active Total Positions = 12
Bar = 82 L=71 S=0 Fail Long SellAtLimit $10.38115 7/2/2009 12:00:00 AM
Bar = 83 Last Position Active Total Positions = 13
Bar = 83 L=71 S=0 Fail Long SellAtLimit $10.38115 7/6/2009 12:00:00 AM
Bar = 84 Last Position Active Total Positions = 14
Bar = 84 L=71 S=0 Fail Long SellAtLimit $9.795 7/7/2009 12:00:00 AM
Bar = 85 Last Position Active Total Positions = 15
Bar = 85 L=71 S=0 Long SellAtLimit $9.795 7/9/2009 12:00:00 AM
Bar = 86 Last Position NOT active Total Positions = 15
Bar = 87 Last Position NOT active Total Positions = 15
Bar = 88 Last Position NOT active Total Positions = 15
Bar = 89 Last Position NOT active Total Positions = 15
Bar = 90 Last Position NOT active Total Positions = 15
Bar = 91 Last Position NOT active Total Positions = 15
Bar = 92 Last Position NOT active Total Positions = 15
Bar = 93 Last Position NOT active Total Positions = 15
Bar = 94 Last Position NOT active Total Positions = 15
Bar = 95 Last Position NOT active Total Positions = 15
Bar = 96 Last Position NOT active Total Positions = 15
Bar = 97 Last Position NOT active Total Positions = 15
CODE:
Please log in to see this code.