Page 1 of 1

PosTradeProfit possible bug

Posted: Apr 29 2014
by tozwp
When using this command with a trade that enters once and exits twice from the entry order, the first exit calculates the profit as though the entire position was filled. The second exit calculates correctly using the reduced size from the entry. I'm using the code below to return the percent gain or loss on each trade.

Code: Select all

for Value1 = 0 to (NumOfTrades - 1) begin
FileAppend("c:\testdata\system.txt",+","+NumToStr((PosTradeProfit(1,value1)/(StartEquity + NetProfit))*100,2)
end;
This code should return the gain or loss percent from each of the exits from an entry. For two exits, the first exit results in a value that equals that of the entire position exiting. The second exit calculates correctly. I then substituted this code and it correctly calculated both exit gain or loss percentages:

Code: Select all

FileAppend("c:\testdata\system.txt",+","+NumToStr((((PosTradeExitPrice(1,value1) - PosTradeEntryPrice(1,value1))*PosTradeSize(1,value1))/(StartEquity + NetProfit))*100,2)
end;
This is making the same loop through the last closed trade sequence from one entry but instead of using the PosTradeProfit command, I used the PosTradeExitPrice, PosTradeEntryPrice and PosTradeSize to calculate the gain or loss. This worked correctly.

Re: PosTradeProfit possible bug

Posted: May 06 2014
by Andrew MultiCharts
Studying the case. Will let know the results as soon as we finish.

Re: PosTradeProfit possible bug  [SOLVED]

Posted: May 08 2014
by Andrew MultiCharts
The issue is fixed in latest MC 8.8 Release 4. Please upgrade: