live-price-tracking_skill

This skill enables real-time live price tracking for NinjaTrader strategies by using OnMarketData and tick data to update trailing stops.
  • C#

0

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill mkalhitti-cloud/universal-or-strategy --skill live-price-tracking

  • SKILL.md12.7 KB

Overview

This skill is a practical guide for implementing live price tracking in NinjaTrader 8 strategies to eliminate delayed trailing stops and other real-time decision bugs. It explains the Close[0] pitfall, the OnMarketData pattern, rate-limited order modifications, and fallbacks for stale feeds. Use it to improve intra-bar execution and reduce missed profit opportunities.

How this skill works

It replaces bar-close-dependent logic with tick-level handling via OnMarketData, filtering for MarketDataType.Last and the current instrument. Indicators are cached on bar close and used during ticks to compute stops without recalculating expensive indicators. A rate limiter ensures order changes comply with broker limits and a last-tick timestamp detects data disconnects.

When to use it

  • Trailing stops that only update at bar close
  • Entry/exit rules that need intrabar accuracy
  • Fixing logic that relies on Close[0] for real-time decisions
  • Detecting and reacting to data feed disconnects
  • Implementing Apex/Rithmic order modification limits

Best practices

  • Filter OnMarketData for MarketDataType.Last and e.Instrument == Instrument
  • Cache indicators in OnBarUpdate; reference cached values in OnMarketData
  • Rate-limit order modifications (e.g., 1 per 1000 ms) to avoid broker penalties
  • Use a GetLivePrice() fallback that prefers midpoint (Bid+Ask)/2, then Ask, then Bid, then Close[0]
  • Log tick counts and last-tick times to verify feed health and detect disconnects

Example use cases

  • Convert a trailing stop that used Close[0] to an OnMarketData-driven update so stops move intra-bar
  • Use GetLivePrice() in entry logic on multi-timeframe charts where OnMarketData may not fire consistently
  • Add disconnect detection to flatten positions if no ticks arrive for a configured threshold (e.g., 5s during RTH)
  • Implement rate-limited ChangeOrder/SetStopLoss to stay within Apex modification rules

FAQ

Close[0] updates only at bar close, so trailing stops based on it will ignore intra-bar favorable moves and can cause missed profits.

How do I avoid recalculating ATR every tick?

Cache ATR in OnBarUpdate and reference the cached value inside OnMarketData; do not call ATR(14)[0] on every tick.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational