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 burtoninlondon, Today, 12:38 AM
          0 responses
          10 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          14 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Yesterday, 08:42 PM
          0 responses
          11 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Yesterday, 07:51 PM
          0 responses
          14 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,983 views
          3 likes
          Last Post jhudas88  
          Working...
          X