MaxContractProfit (Reserved Word)
Calculates the Maximum Position Profit per contract or share. MaxContractProfit will divide the complete position profit by the number of contracts/shares for the maximum position profit for a single share/contract
MaxContractProfit
Remarks
The reserved words ContractProfit and MaxContractProfit include both closed profits and losses and open profits and losses in their calculations. The sum of open and closed P&L is then divided by only the number of shares in the open position to obtain the value returned by ContractProfit or MaxContractProfit. For this reason, when scaling out of a position using exits that do not exit the entire position all at once, the values returned by these reserved words will not be the profit or max profit per open contract or share. Instead, the value returned is the result of this calculation:
ContractProfit = ( Closed P&L + Open P&L ) / Number of Open Shares (or contracts)
If it is desired to calculate the profit per open share or contract, the following formula may be implemented in your EasyLanguage strategy:
Variables: PerSharePL( 0 ) ;
If CurrentShares <> 0 then
PerSharePL = OpenPositionProfit / CurrentShares ;
The same value can be calculated by the formula, since CurrentContracts and CurrentShares are synonymous and do not depend upon the type of security traded:
If CurrentContracts <> 0 then
PerSharePL = OpenPositionProfit / CurrentContracts ;
Example
Value1 will hold the maximum position profit for the current position.
Value1 = MaxContractProfit;
Additional Example
If you wanted to exit a long position after the profit per share reached $25, you could use the following syntax:
If MaxContractProfit >= 25 Then
Sell This Bar on Close;