AveragePrice

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference > Strategy > Position >

AveragePrice

Previous page Return to chapter overview Next 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.AveragePrice

 

 

Examples

ns


protected override void OnBarUpdate()
{
    // Raise stop loss to breakeven when there is at least 10 ticks in profit
    if (Close[0] >= Position.AveragePrice + 10 * TickSize)
        ExitLongStopMarket(Position.Quantity, Position.AveragePrice);
}