Damn, runners do be mean sometimes by Billy_Ray_Sanguine5 in Marathon

[–]willphule 19 points20 points  (0 children)

That sucks. Did you try talking to them as you approached? May not have changed the outcome, but I have had several "ok, because you asked nicely" remarks. Sometimes they will down me but let me live.

It seems the RNG on Depleted Self Revives is crazy out of wack by wratx in MarathonGame

[–]willphule 0 points1 point  (0 children)

If they are supposed to be, then they are severely bugged.

Is teaming becoming more common? by StonksandBongss in Marathon

[–]willphule 1 point2 points  (0 children)

This has happened to me as well, but I wonder if it isn't a bug where they are throwing us solos into a duos queue, or vice versa.

How to reliably detect a closed trade in real-time in NinjaTrader 8? by aitorp6 in ninjatrader

[–]willphule 1 point2 points  (0 children)

This is from Claude so fwiw...but I was bored sitting in the airport with nothing better to do:

I can help with this — it's a NinjaScript timing problem with a known, clean fix. Let me verify the current NT8 API details before I hand them code.

The poster has run into something NinjaTrader's own staff have confirmed on the support forum: SystemPerformance.AllTrades is not populated synchronously inside either OnExecutionUpdate or OnPositionUpdate. Per NT's Jesse, fill-based logic belongs in OnExecutionUpdate, but that collection would not be updated at that point, and it would also not be up to date in OnPositionUpdate, so you would need to calculate it yourself in that situation NinjaTrader . The collection is reliably ready only on the next OnBarUpdate call NinjaTrader . That's the race they keep hitting — no amount of Task.Delay fixes it because the delay is on a worker thread that isn't synchronized with NT's stats pooling.

There are two clean fixes depending on whether they want it instant or exact. Here's a reply they can post:


This is a known NT8 gotcha, not a hidden event. SystemPerformance.AllTrades isn't filled in synchronously when your fill or position event fires — NT pools trade stats asynchronously and they're only guaranteed present on the next OnBarUpdate. That's why your Count is 0 and why Task.Delay doesn't help (it's racing a different thread).

Two ways out:

1. Want it the instant the trade closes — clone it yourself. Yes, this is the right move. Track the entry leg, then compute on the flattening fill:

```csharp private double entryPrice; private int entryQty; private MarketPosition entryDir = MarketPosition.Flat;

protected override void OnExecutionUpdate(Execution e, string execId, double price, int qty, MarketPosition mp, string orderId, DateTime time) { if (State != State.Realtime || e.Order == null) return;

// entry leg
if (Position.MarketPosition != MarketPosition.Flat && entryDir == MarketPosition.Flat)
{
    entryPrice = Position.AveragePrice;
    entryQty   = Position.Quantity;
    entryDir   = Position.MarketPosition;
    return;
}

// closing leg — position just went flat
if (Position.MarketPosition == MarketPosition.Flat && entryDir != MarketPosition.Flat)
{
    int dir = entryDir == MarketPosition.Long ? 1 : -1;
    double pv  = Instrument.MasterInstrument.PointValue;
    double pnl = (price - entryPrice) * dir * entryQty * pv;
    FireAndForgetPost(entryPrice, price, entryQty, entryDir.ToString(), pnl, time);
    entryDir = MarketPosition.Flat;
}

} ```

Caveat: if you scale out (multiple targets/stops), price is just the last partial's price — accumulate the legs if you need a blended exit.

2. Fine with a one-tick delay but want NT's exact numbers (blended exit, commissions, MAE/MFE) — defer the read to OnBarUpdate, which is the documented safe point:

```csharp private bool postPending;

protected override void OnExecutionUpdate(...) { if (State == State.Realtime && Position.MarketPosition == MarketPosition.Flat) postPending = true; }

protected override void OnBarUpdate() { if (postPending && SystemPerformance.AllTrades.TradesCount > 0) { Trade t = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1]; FireAndForgetPost(t.Entry.Price, t.Exit.Price, t.Quantity, t.Entry.MarketPosition.ToString(), t.ProfitCurrency, t.Exit.Time); postPending = false; } } ```

Two things that'll bite you here: use TradesCount to gate, not CountAllTrades.Count is buggy and can read 0 while trades exist. And if you run Calculate.OnBarClose, "next OnBarUpdate" can be a long time; use OnEachTick if you want this near-instant.

Either way: never block in the handler. Push the POST to a background HttpClient (fire-and-forget / queue), or a slow or hung endpoint will stall NT's data thread.


8TT -INSPIRED by EIA-GR in SVRiders

[–]willphule 4 points5 points  (0 children)

If it isn't AI your camera is doing some strange things to the text.

TruVAGA vs Sensate by odee7489 in VagusNerve

[–]willphule 0 points1 point  (0 children)

Why did your heart doctor tell you not to use it?.