NinjaScript > Language Reference > Strategy >

EntriesPerDirection

Print this Topic Previous pageReturn to chapter overviewNext page

Definition

Indicates the maximum number of entries allowed per direction while a position is active based on the EntryHandling property.

 

Property Value

An int value represents the maximum number of entries allowed.

 

Syntax

EntriesPerDirection

 

 

Examples

// Example #1
// If an open position already exists, subsequent EnterLong() calls are ignored.
protected override void Initialize()
{
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
}

 

protected override void OnBarUpdate()
{
    if (CrossAbove(SMA(10), SMA(20), 1)
         EnterLong("SMA Cross Entry");
 
    if (CrossAbove(RSI(14, 3), 30, 1)
         EnterLong("RSI Cross Entry);
}

 

// Example #2
// EnterLong() will be processed once for each uniquely named entry.
protected override void Initialize()
{
     EntriesPerDirection = 1;
     EntryHandling = EntryHandling.UniqueEntries;
}

 

protected override void OnBarUpdate()
{
    if (CrossAbove(SMA(10), SMA(20), 1)
         EnterLong("SMA Cross Entry");
 
    if (CrossAbove(RSI(14, 3), 30, 1)
         EnterLong("RSI Cross Entry);
}