Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position AveragePrice not working live

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

    Position AveragePrice not working live

    So first off, my code is fine on the Playback connection but not Tradovate in NT. I am trying to read Position.AveragePrice on the Tradovate data connection but receiving 0. This is messing up the stop setups using ExitShortStopMarket or ExitLongStopMarket.

    stopLoss = 30 ticks
    TickSize = 0.25 (es)

    Playback example

    Position.AveragePrice + stopLoss * TickSize = 4128.25

    Tradovate data/live

    Position.AveragePrice + stopLoss * TickSize = 7.5

    Snippit from NS Output with TraceOrders on:

    Breakeven Enabled - Setting Stop to StopLoss - stopSet is False Position.AveragePrice + stopLoss * TickSize = stopLoss = 7.5
    2/6/2023 12:15:05 PM Strategy '': Entered internal SubmitOrderManaged() method at 2/6/2023 12:15:05 PM: BarsInProgress=0 Action=BuyToCover OrderType=StopMarket Quantity=4 LimitPrice=0 StopPrice=7.50 SignalName='TradeEntry' FromEntrySignal='TradeEntry'
    2/6/2023 12:15:05 PM Strategy '': Ignored SubmitOrderManaged() method at 2/6/2023 12:15:05 PM: BarsInProgress=0 Action=BuyToCover OrderType=StopMarket Quantity=4 LimitPrice=0 StopPrice=7.50 SignalName='TradeEntry' FromEntrySignal='TradeEntry' Reason='This was an exit order but no position exists to exit'
    Disabling NinjaScript strategy ''
    Enabling NinjaScript strategy '' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On each tick IsUnmanaged=False MaxRestarts=4 in 5 minutes
    2/6/2023 12:15:06 PM Strategy '': Entered internal SubmitOrderManaged() method at 2/6/2023 12:15:06 PM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=4 LimitPrice=0 StopPrice=0 SignalName='TradeEntry' FromEntrySignal=''

    This is how it appears in Playback:

    Breakeven Enabled - Setting Stop to StopLoss - stopSet is False Position.AveragePrice + stopLoss * TickSize = stopLoss = 4128.25
    2/6/2023 12:15:06 PM Strategy '': Entered internal SubmitOrderManaged() method at 2/6/2023 12:15:06 PM: BarsInProgress=0 Action=BuyToCover OrderType=StopMarket Quantity=4 LimitPrice=0 StopPrice=4128.25 SignalName='TradeEntry' FromEntrySignal='TradeEntry'​


    #2
    Hello klak1212,

    If you are using the tradovate beta connection you need to use the platform to do a report.

    Please report any issues you encounter or feedback via Help > Email Support in the NinjaTrader platform and using "Tradovate Adapter Beta Report" as the subject line while keeping the default log/trace file upload checked.
    Because this relates to a strategy and its code please form a very simple example before emailing support. A simple example would be similar to the SampleMACrossOver that only has a few lines of code. That sample should show the problem and exclude your custom logic/conditions. Please include the steps you used to see the problem as well. You can attach the sample as a zip file using the Attachment button in the Email Support window.



    Comment


      #3
      It's fine now. Because I switched from Set stop types to Exit methods, I needed to start using OnExecutionUpdate instead of OnBarUpdate for creating orders. I guess because of the delay to the broker.

      Comment


        #4
        Hello klak1212,

        It sounds like you may have just potentially hit a normal situation in NinjaScript with the new details. The Position won't be updated until 1 OnBarUpdate event happens after the entry fills. If you were checking it right after submitting an entry from OnBarUpdate that would be why its not correct.

        The detail you mentioned about using OnExecutionUpdate is also normal for creating target orders, targets are submitted based on the entry fill in most situations. After that point or when you see the entry had filled the position information would start being updated as well.

        There is a sample strategy that uses OnExecutionUpdate to submit targets and shows the general flow of how a strategy would be intended to operate based on the order events. If your changes are similar to that sample then that would confirm you have made a valid solution: https://ninjatrader.com/support/help...and_onexec.htm

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X