• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculating and setting value for PositionDisplay

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

    Calculating and setting value for PositionDisplay

    Hi.

    We have a panel that has buttons and a PositionDisplay control so it looks a bit similar to ChartTrader. We know to set the properties AveragePrice, Position, PnL, and PnLValue so PositionDisplay will display same info as found in ChartTrader.

    We calculate PnL from inside our strategy then call ourPanel.SetPnL(calculatedPnL). The problem is when calculating value for PnL. It's correct when there's only one order but when there's more then it starts to differ by at least .125. We calculate pnl using:

    Code:
    (marketDataUpdate.Price - Position.AveragePrice) * Position.MarketPosition == MarketPosition.Long ? 1 : -1
    We've tried the Points formula found here (https://ninjatrader.com/support/help...tion_modes.htm) and looks like:

    Code:
    (1 for Long position, or -1 for short position) * Quantity * (Exit Price - Entry Price - Entry Commission - Exit Commission) / (Exit Rate * Point Value) / Lot Size
    For Exit/Entry Price/Commision/Rate, we use OnExecutionUpdate(Execution execution, ...) handler to set vars _LastEntry/_LastExit, checking execution.IsEntry/IsExit before setting the vars.
    PointValue = this.Instrument.MasterInstrument.PointValue
    Lot Size = Account.ForexLotSize

    but its result differs from what I see in ChartTrader.

    And also by clicking on bottom part of PositionDisplay control it switches between calculation mode from points to pips, ticks, currency, percentage.

    Is there a built-in calculate method that takes a CalculationMode parameter that one can call to calculate Profit and Loss? If not, how to properly calculate for those different calculation mode?

    Thank you.
    Last edited by cmarkb; 10-27-2019, 10:39 PM. Reason: positiondisplay, pnl

Latest Posts

Collapse

Topics Statistics Last Post
Started by GLFX005, Today, 12:22 PM
2 responses
35 views
0 likes
Last Post NinjaTrader_Kate  
Started by AspenHiker, Today, 08:37 AM
1 response
10 views
0 likes
Last Post NinjaTrader_Kate  
Started by MartinT, Yesterday, 01:12 PM
3 responses
15 views
0 likes
Last Post MartinT
by MartinT
 
Started by caveat_lector, Today, 11:58 AM
1 response
7 views
0 likes
Last Post NinjaTrader_Heath  
Started by Bionian, Today, 11:43 AM
1 response
10 views
0 likes
Last Post NinjaTrader_Kate  
Working...
X