PosTradeProfit possible bug  [SOLVED]

Questions about MultiCharts and user contributed studies.
tozwp
Posts: 145
Joined: 15 Apr 2011
Has thanked: 16 times
Been thanked: 8 times

PosTradeProfit possible bug

Postby tozwp » 29 Apr 2014

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.

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: PosTradeProfit possible bug

Postby Andrew MultiCharts » 06 May 2014

Studying the case. Will let know the results as soon as we finish.

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: PosTradeProfit possible bug  [SOLVED]

Postby Andrew MultiCharts » 08 May 2014

The issue is fixed in latest MC 8.8 Release 4. Please upgrade:


Return to “MultiCharts”