Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Trade info on chart not working with US stocks but fine on FOREX

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

    Trade info on chart not working with US stocks but fine on FOREX

    Hello,
    This code below works great on I my chart is referencing Forex data. But as soon as I switch to a stock (UPRO), the output always reads "0". What am I missing? (My brokers/feeds are FOREX.com and Interactive Brokers).

    Draw.TextFixed(this, "Position.GetUnrealizedProfitLoss", "Current Gains_"+ Convert.ToString(Position.GetUnrealizedProfitLoss( PerformanceUnit.Currency)), TextPosition.TopLeft);

    #2
    Ya know, I almost always figure it out AFTER I ask you guys. Ha. This works (change in bold):

    Draw.TextFixed(this, "Position.GetUnrealizedProfitLoss", "Open Profit_"+ Convert.ToString(Position.GetUnrealizedProfitLoss( PerformanceUnit.Currency, Close.GetValueAt(CurrentBar))), TextPosition.TopLeft);

    Comment


      #3
      Hello White Fork,

      I would still expect the last price being substituted to work.

      From the help guide:
      "If no double argument is provided in the call, the current (real-time) Last price will be substituted in."


      To confirm Position.GetUnrealizedProfitLoss( PerformanceUnit.Currency) is always producing a 0, even when there is profit or loss in an open position?
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        "0", that is correct. On all Stocks and some Currencies depending on the decimal place. (Maybe it's an "int" thing?)

        Comment


          #5
          Hello White Fork,

          I am not able to reproduce this behavior.

          If you follow the exact steps shown in the video are you experiencing different behavior?
          Attached Files
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Belfortbucks, Today, 09:29 PM
          0 responses
          3 views
          0 likes
          Last Post Belfortbucks  
          Started by zstheorist, Today, 07:52 PM
          0 responses
          7 views
          0 likes
          Last Post zstheorist  
          Started by pmachiraju, 11-01-2023, 04:46 AM
          8 responses
          150 views
          0 likes
          Last Post rehmans
          by rehmans
           
          Started by mattbsea, Today, 05:44 PM
          0 responses
          6 views
          0 likes
          Last Post mattbsea  
          Started by RideMe, 04-07-2024, 04:54 PM
          6 responses
          33 views
          0 likes
          Last Post RideMe
          by RideMe
           
          Working...
          X