PriceLevels Collection

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference > Common > Drawing >

PriceLevels Collection

Previous page Return to chapter overview Next page

Definition

A collection of PriceLevel objects defining lines for multi-price-level Drawing Tools (Fibonacci tools, etc.). Each PriceLevel within the collection can be configured programmatically or analyzed to obtain the parameters of user-drawn objects.

 

Note: PriceLevels is only used with the following pre-built Drawing Tools, but it can be used with custom Drawing Tools, as well:

 

 

 

Syntax

PriceLevels[int idx]
PriceLevels[int idx].GetPrice(double startPrice, double totalPriceRange, bool isInverted)
PriceLevels[int idx].GetY(ChartScale chartScale, double startPrice, double totalPriceRange, bool isInverted)

 

Methods and Properties

GetPrice()

Returns a double which repents the price value at the specified price level

GetY()

Returns a float representing the y-pixel coordinate at the specified price level

Name

The Name property of the specified PriceLevel. Set to a formatted version of Value by default.

Stroke

The Stroke used to draw the line associated with the specified PriceLevel

Tag

A tag used to identify the specified PriceLevel. Null by default.

Value

The value of the PriceLevel in percentage terms

 

 

 

Examples

ns


// Define a FibonacciRetracements object outside of OnBarUpdate(), so the same object can be re-used
FibonacciRetracements myRetracements;
 
protected override void OnBarUpdate()
{
 
  if (CurrentBar < 20)
    return;
 
  // Instantiate myRetracements
  myRetracements = Draw.FibonacciRetracements(this, "fib", true, 20, High[20], 2, Low[2]);
 
  // Print each price level in the PriceLevels collection contain in myRetracements
  foreach (PriceLevel p in myRetracements.PriceLevels)
  {
    Print(p.Value);
  }
}