Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Realtime update

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Realtime update

    I'd like my PnL to update on every tick, I can see the bid and ask updating but the PNL only updates on bar close.. I do have CalculateOnBarClose = true;

    protected override void OnMarketData(MarketDataEventArgs e)
    {
    if(Time[0].DayOfWeek != DayOfWeek.Wednesday)
    {
    local = DateTime.Now;
    double a=e.MarketData.Ask.Volume;
    double b=e.MarketData.Bid.Volume;
    DrawTextFixed("tradetimes","Bid "+a.ToString()+ " Ask "+b.ToString()+ "\n"+local.ToString(),TextPosition.BottomRight,Col or.Black,new Font("Arial",10),Color.Black,Color.Yellow,5);
    DrawTextFixed("PNLd"," Open PnL:$ "+Position.GetProfitLoss(GetCurrentAsk(), PerformanceUnit.Currency).ToString("0.00")+ " Closed PNL:$"+ profit.ToString("0.00")+ " #Trades: "+ (tradectr/2).ToString()+" " ,TextPosition.BottomLeft,Color.White,textFont,Colo r.Black,Color.Black,12);

    }

    #2
    Hello gg80108,

    Thank you for your note.

    I have had a chance to test the code that you have supplied. I was able to verify does indeed run on every tick. This includes the PnL on the second draw text.

    I added a position change to the beginning of onMarketUpdate and the PnL did reflect this position before the end of the first bar. (I'm using a 10 minute chart).

    The PnL will only update once you are in a position and there has been movement of greater than 1 tick.

    To know if the PnL should be changing I would need to review your completed script as there are no position changes in your supplied code.


    Please let me know if I can be of further assistance.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    666 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    377 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    110 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    575 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    580 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X