Performance Report: # of Contracts Traded? [SOLVED]
- furytrader
- Posts: 354
- Joined: 30 Jul 2010
- Location: Chicago, IL
- Has thanked: 155 times
- Been thanked: 217 times
Performance Report: # of Contracts Traded?
Is there some place in the standard performance report to see how many contracts were traded historically? I am testing a system that gets in with 3 contracts, exits 2 contracts at a target price and holds on to 1 contract, with a trailing stop. I can see how many trades there were, but each "trade" may consist of 1, 2 or 3 contracts. Besides counting the individual number of contracts, what's the best way to tell how many contracts were traded?
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Performance Report: # of Contracts Traded?
Hello Furytrader,
You can find the contracts amount in:
Performance Report-> Trade analysis->List of trades->Contracts column.
You can find the contracts amount in:
Performance Report-> Trade analysis->List of trades->Contracts column.
- furytrader
- Posts: 354
- Joined: 30 Jul 2010
- Location: Chicago, IL
- Has thanked: 155 times
- Been thanked: 217 times
Re: Performance Report: # of Contracts Traded?
But that doesn't aggregate them. It just says that for some trades, I did 3 contracts, with other trades I did 2 contracts, etc. Is there a way to get a complete tally of the total # of contracts traded?
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Performance Report: # of Contracts Traded?
Besides counting the individual number of contracts, what's the best way to tell how many contracts were traded?
Yes, there's a custom way in which you can get the total number of contracts traded. PosTradeCount() and PosTradeSize() are in this regard the keywords that you'll need for this.Is there a way to get a complete tally of the total # of contracts traded?
However, since there isn't a keyword for the number of positions, you'll need to manually count these (which gives extra code). Then, on the last bar, you'll need to loop through all positions.
You'll need two loops for this: one for the number of positions (which you manually tracked), and one the number of entries in that position (which is given by PosTradeCount). Then you can use the PosTradeSize (which gives the size of each entry order for that specified position) to calculate the number of contracts traded.
Perhaps you already know this, but just to be complete, if you enter a trade with 4 contracts (so one entry order), and then have two separate exit orders each for 2 contracts, according to the PosTradeCount keyword, you have had two entries. (somewhat counter-intuitive , but I suppose it's needed for order matching). Anyway, also see this wiki article for a better example of that.
If I understand you correctly FuryTrader, the code example should get you started. It performs the actions that I described above:
Code: Select all
[IntrabarOrderGeneration = True]
Variables:
x(0), y(0),
IntrabarPersist NumberOfPositions(0), // Positions <> TotalTrades
IntrabarPersist MPPosSize(0),
IntrabarPersist PrevMPPosSize(0),
numOfContracts(0);
// Get current position
MPPosSize = CurrentContracts * MarketPosition(0);
// Look for a recently closed position
if ( (PrevMPPosSize < 0) and (MPPosSize > 0) ) or // Previous position was short, now long
( (PrevMPPosSize > 0) and (MPPosSize < 0) ) or // Previous position was long, now short
( (PrevMPPosSize <> 0) and (MPPosSize = 0) ) then begin // Previous position was not flat, now flat
NumberOfPositions = NumberOfPositions + 1;
end;
// Start counting the number of contracts
if (BarStatus(1) = 2) and (LastBarOnChart_s = True) and (GetAppInfo(aiOptimizing) <> 1) then begin
Print("*************************");
Print("Total trades executed by ", GetStrategyName, ": ", NumToStr(TotalTrades, 0));
Print("Total number of positions: ", NumToStr(NumberOfPositions, 0));
numOfContracts = 0;
// Loop through positions
for x = 0 to NumberOfPositions begin
// Loop through trades of the position
for y = 0 to PosTradeCount(x) - 1 begin
numOfContracts = numOfContracts + PosTradeSize(x, y);
end; //: Trades loop
end; //: Position loop
Print("Total number of contracts traded: ", NumToStr(numOfContracts, 0));
Print("*************************");
end;
// Store current position size for comparisons
PrevMPPosSize = MPPosSize;
Code: Select all
*************************
Total trades executed by TestStrategy6: 4389
Total number of positions: 1463
Total number of contracts traded: 4392
*************************
- furytrader
- Posts: 354
- Joined: 30 Jul 2010
- Location: Chicago, IL
- Has thanked: 155 times
- Been thanked: 217 times
Re: Performance Report: # of Contracts Traded? [SOLVED]
This is great - thank you very much for taking the time to do this. However, it sounds like this would be something relatively easy to add to the performance report. I am going to add a request in the project manager and see if they add it - thanks again Josh!