NinjaScript > Language Reference > Strategy > Position >

AvgPrice

Print this Topic Previous pageReturn to chapter overviewNext page

Definition
Gets the average price of a strategy position.

 

Property Value

A double value representing the position's average price per unit.

 

Syntax

Position.AvgPrice

 

Examples

protected override void OnBarUpdate()
{

    // Raise stop loss to breakeven when there is at least 10 ticks in profit
    if (Close[0] >= Position.AvgPrice + 10 * TickSize)

         ExitLongStop(Position.Quantity, Position.AvgPrice);
}