Skip to main content

IIndicator

Root interface for all MZpack indicators. Defines the contract for chart interaction, candle data access, price arithmetic, lifecycle state, and logging.

Namespace: MZpack

Candle & Bar Data

MethodReturnsDescription
GetCandle(int ago)ICandleGet candle N bars ago (0 = current)
GetCandleByBarIdx(int barIdx)ICandleGet candle by absolute bar index
GetCandleByBarIdx(int dataSeriesIdx, int barIdx)ICandleGet candle from a specific data series
GetBarHigh(int idx)doubleBar high price by index
GetBarLow(int idx)doubleBar low price by index
GetBarTime(int idx)DateTimeBar time by index
GetBarTime(int idx, int barsIdx)DateTimeBar time from a specific bars series

Price Utilities

MethodReturnsDescription
RoundToTickSize(double)doubleRound price to nearest tick
PriceDiffTicks(double, double)intDifference between two prices in ticks
PriceAddTicks(double, int)doubleAdd N ticks to a price
PriceAddTick(double)doubleAdd one tick
PriceSubtractTick(double)doubleSubtract one tick
Compare(double, double)intCompare two prices (−1, 0, 1)
GetCurrentBid()doubleCurrent best bid
GetCurrentAsk()doubleCurrent best ask

Chart Coordinate Conversion

MethodReturnsDescription
GetYByPrice(double)floatConvert price to Y pixel coordinate
GetValueByY(float)doubleConvert Y pixel to price value
GetXByBarIdx(int)floatConvert bar index to X pixel
GetBarIdxByX(float)intConvert X pixel to bar index
GetXByTime(DateTime)intConvert time to X pixel
GetTimeByX(int)DateTimeConvert X pixel to time
GetBarIdXByTime(DateTime)intConvert time to bar index
GetCloseTimeByBarIdx(int)DateTimeBar close time by index
GetTickHeight()floatHeight of one tick in pixels
GetBarWidth()floatWidth of one bar in pixels
GetBarSpace()floatSpacing between bars
GetChartBounds()RectangleFChart area bounds

Lifecycle State

PropertyTypeDescription
IsConnectedboolData connection is active
IsRealtimeboolIndicator is in real-time mode
IsWorkingboolIndicator is actively processing
IsTickReplayboolTick Replay is enabled
IsOnBarCloseboolCalculate on bar close (vs each tick)
IsHistoricalBidAskboolHistorical bid/ask data available
UsageModeIndicatorModeChart or Strategy
WorkingTimeFilterboolWorking time filter is active
HasInstrumentboolInstrument is assigned

Bar Context

PropertyTypeDescription
__CurrentBarintCurrent bar index
__BarsInProgressintIndex of the data series currently being processed
__IsFirstTickOfBarboolCurrent tick is the first of a new bar
__IsFirstBarOfSessionboolCurrent bar is the first of the session
__TickSizedoubleInstrument tick size
Is1TickChartboolChart uses 1-tick bar type
IsMinuteChartboolChart uses minute bar type
ChartBarsPeriodSecondsintBar period in seconds
ChartBarsValueintBar period value
DataSeriesIndexintData series index for multi-series strategies

Data Model

PropertyTypeDescription
ModelIncrementRefreshModelIncrementRefreshHow data model is refreshed: Realtime or HistoricalRealtime
ModelRefreshGranularityModelRefreshGranularityRefresh granularity: Tick, Bar, or ModelItem
CalcModelItemWhileCollectingCalculateModelItemWhen to calculate: OnEachTick or OnBarClose

Rendering & UI

Property / MethodTypeDescription
VisibleboolIndicator visibility on chart
__IsOverlayboolRender as overlay on price panel
__MinValue / __MaxValuedoubleY-axis range
ChartRightMarginintRight margin in pixels
ForceRefreshChart()voidForce immediate chart repaint
RefreshChart()voidRequest chart repaint
InvalidateChartVisual()voidInvalidate chart visual
SyncobjectLock object for thread-safe access

Logging

MethodDescription
__Print(string)Print to NinjaScript Output
LogInformation(string)Log info message
LogWarning(string)Log warning
LogAlert(string)Log alert
LogError(string)Log error
LogException(Exception)Log exception
DefaultAlert(string, string)Trigger default alert with message and sound file
ShowMessage(string, MessageBoxImage)Show message box

Notification

MethodDescription
Notify(QuoteEventArgs)Notify indicator of a quote update
Notify(ExecutionEventArgs)Notify of a trade execution
Notify(Trade)Notify of a reconstructed trade
Notify(Notification)Send a custom notification

IndicatorMode Enum

ValueDescription
ChartIndicator runs on a chart
StrategyIndicator runs inside a strategy

Derived Interfaces

InterfaceAdds
ITickIndicator / IOrderFlowIndicatorMarket data, order flow configuration
ILevelsIndicatorInteractive horizontal price levels