Skip to main content

Entry

Entry handles order submission and protective orders (stop loss, profit target, breakeven) within a pattern. Several specialized subclasses provide alternative stop loss and entry price calculations.

Namespace: MZpack.NT8.Algo Inheritance: Entry : EntryBase Source: [INSTALL PATH]/API/Extensions/Entries/Entry.cs

EntryBase​

Abstract base class for all entry types.

PropertyTypeDescription
SignalNamestringUnique name of the entry
TypeNamestringRead-only, returns the class name
TrailTrailBaseTrailing stop attached to this entry
ExitExitBaseExit condition attached to this entry

Abstract methods: GetStopLossValue(), GetProfitTargetValue().

Entry Properties​

Order Configuration​

PropertyTypeDefaultDescription
Quantityint1Number of contracts
EntryMethodEntryMethodMarketOrder type: Market, Limit, or StopLimit
LimitEntryShiftTicksint0Tick offset for limit entry price
LimitEntryPriceChaseboolfalseMove pending limit order tick by tick
CancelLimitOrderTypeCancelLimitOrderTypeBarsWhen to cancel a pending limit order
CancelLimitOrderValuedouble1Value for CancelLimitOrderType

Stop Loss​

PropertyTypeDefaultDescription
StopLossCalculationModeCalculationModeTicksTicks or Price
StopLossTicksint6Stop loss distance in ticks
StopLossPricedouble—Stop loss price (when mode is Price)

Profit Target​

PropertyTypeDefaultDescription
ProfitTargetCalculationModeCalculationModeTicksTicks or Price
ProfitTargetTicksint12Profit target distance in ticks
ProfitTargetPricedouble—Profit target price (when mode is Price)

Breakeven​

PropertyTypeDefaultDescription
IsBreakEvenboolfalseEnable breakeven stop
BreakEvenAfterCalculationModeCalculationModeTicksTicks or Price
BreakEvenAfterTicksint8Ticks of profit before breakeven activates
BreakEvenAfterPricedouble—Price for breakeven activation
BreakEvenShiftTicksint0Ticks added to breakeven stop (positive = extra profit)

Read-Only State​

PropertyTypeDescription
FilledintFilled quantity
AverageEntryPricedoubleAverage fill price
IsInBreakEvenboolTrue if breakeven stop is active
BreakEvenPricedoubleCurrent breakeven stop price
HasPendingLimitOrderboolTrue if a limit order is pending
FilledBarIdxintBar index when order was filled
IsStopLossTriggeredboolTrue if stop loss was hit
IsProfitTargetTriggeredboolTrue if profit target was hit

Entry Methods​

MethodDescription
Initialize(Strategy strategy, Position position)Bind to strategy and position
Reset()Reset fill state, breakeven, and triggers
SubmitStopLoss(DateTime time, int quantity, double value, CalculationMode mode)Submit initial stop loss
ChangeStopLoss(DateTime time, int quantity, double value, CalculationMode mode)Modify existing stop loss
SubmitProfitTarget(DateTime time, int quantity, double value, CalculationMode mode)Submit profit target
GetEntryPrice(double entry)Override to calculate custom entry price
GetPnL()Returns unrealized PnL

BarStopLossEntry​

Sets the stop loss from the high or low of a bar N bars ago.

Inheritance: BarStopLossEntry : Entry

Properties​

PropertyTypeDefaultDescription
StopLossBarsAgoint1Bars ago for stop loss reference bar
StopLossShiftTicksint1Tick shift from bar high/low

Stop Loss Calculation​

  • Long: Min(CurrentBid - spread, Low[BarsAgo] - ShiftTicks)
  • Short: Max(CurrentAsk + spread, High[BarsAgo] + ShiftTicks)

Sets StopLossCalculationMode = Price automatically.


SignalStopLossEntry​

Uses the signal-calculated StopLossPrice property to set the stop loss.

Inheritance: SignalStopLossEntry : Entry

Properties​

PropertyTypeDefaultDescription
StopLossShiftTicksint1Tick shift from signal stop loss price

Stop Loss Calculation​

  • Long: Min(CurrentBid - spread, StopLossPrice - ShiftTicks)
  • Short: Max(CurrentAsk + spread, StopLossPrice + ShiftTicks)

Sets StopLossCalculationMode = Price automatically.


FiboRetracementEntry​

Places a limit entry at a Fibonacci retracement level between swing high and swing low.

Inheritance: FiboRetracementEntry : Entry

Properties​

PropertyTypeDefaultDescription
Fibodouble50.0Fibonacci retracement percentage
SwingHighdouble—Swing high price
SwingLowdouble—Swing low price

Entry Price Calculation​

Retracement = (SwingHigh - SwingLow) * Fibo / 100

  • Long: SwingHigh - retracement (must be < CurrentAsk)
  • Short: SwingLow + retracement (must be > CurrentBid)

Returns 0 if the price constraint is violated. Sets EntryMethod = Limit automatically.


Enums​

EntryMethod​

ValueDescription
MarketMarket order
LimitLimit order
StopLimitStop-limit order

CancelLimitOrderType​

ValueDescription
NoneNever cancel
TicksCancel after N ticks move
BarsCancel after N bars
MillisecondsCancel after N milliseconds

CalculationMode​

ValueDescription
TicksValue in ticks
PriceAbsolute price

See Also​

  • Pipeline — execution order of components
  • Position — position management
  • Exit — exit conditions
  • Trail — trailing stop management