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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    63 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    35 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    54 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    61 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    48 views
    0 likes
    Last Post CarlTrading  
    Working...
    X