+1 888 340 6572

PositionProfit: Difference between revisions

From MultiCharts
No edit summary
No edit summary
 
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Returns a numerical value, indicating the profit or loss for the specified position.  
Returns a numerical value, indicating the total realized profit or loss for the specified closed position.  
   
   
== Usage ==
== Usage ==
Line 6: Line 6:
Where:  
Where:  


:'''PosBack - a numerical expression, specifying the position:  
:'''PosBack''' - a numerical expression, specifying the closed position:
 
::'''0''' - current position;


::'''0''' - open position;
             
::'''1''' - one position back (the last position closed);  
::'''1''' - one position back (the last position closed);  
                
                
::'''2''' - two positions back, etc.  
::'''2''' - two positions back, etc.  


If '''PosBack''' is not specified, a value for the open position will be returned.  
PositionProfit with '''PosBack''' unspecified equals PositionProfit(0).
 
In order to return the current unrealized profit or loss of an open position please use [[OpenPositionProfit]] keyword.
 
== Notes ==
== Notes ==
* This function can only be used in signals.  
* This function can only be used in signals.  
   
   
== Example ==
== Example ==
<syntaxhighlight>PositionProfit</syntaxhighlight>
<syntaxhighlight>PositionProfit(1)</syntaxhighlight>
Will return a value of 0 if the current position is flat.
Returns a value of -5 if the most recently closed position has generated $5 loss.


<syntaxhighlight>PositionProfit(0)</syntaxhighlight>
<syntaxhighlight>PositionProfit(0)</syntaxhighlight>
Will return a value of 5 if the value of the open position has increased by $5 since it was entered.
Returns a value of 0 if the position is open and there were no partial exits from it.


<syntaxhighlight>PositionProfit(1)</syntaxhighlight>
<syntaxhighlight>PositionProfit(0)</syntaxhighlight>
Will return a value of -5 if the most recently closed position has generated a loss of $5.
Returns a value of 5 if the position was partially closed with $5 profit.
 
<syntaxhighlight>PositionProfit(0)</syntaxhighlight>
Returns a value of 0 if there is no open position.
   
   
[[Category:Strategy Position]]
[[Category:Strategy Position]]

Latest revision as of 10:47, 14 June 2023

Returns a numerical value, indicating the total realized profit or loss for the specified closed position.

Usage

PositionProfit(PosBack)

Where:

PosBack - a numerical expression, specifying the closed position:
0 - current position;
1 - one position back (the last position closed);
2 - two positions back, etc.

PositionProfit with PosBack unspecified equals PositionProfit(0).

In order to return the current unrealized profit or loss of an open position please use OpenPositionProfit keyword.

Notes

  • This function can only be used in signals.

Example

PositionProfit(1)

Returns a value of -5 if the most recently closed position has generated $5 loss.

PositionProfit(0)

Returns a value of 0 if the position is open and there were no partial exits from it.

PositionProfit(0)

Returns a value of 5 if the position was partially closed with $5 profit.

PositionProfit(0)

Returns a value of 0 if there is no open position.