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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    50 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    16 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    22 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    23 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X